Skip to content

Commit

Permalink
Merge pull request #58 from crysxd/fix-renaming
Browse files Browse the repository at this point in the history
Fix renaming
  • Loading branch information
crysxd authored Feb 20, 2024
2 parents 4635616 + 61e0b13 commit 1fb16e0
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ignore=CVS,Proto

# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths.
ignore-paths=octoeverywhere/Proto
ignore-paths=octoapp/Proto

# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths.
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
// The module requires this json object to be passed.
// Normally the install.sh script runs, ensure everything is installed, creates a virtural env, and then runs this modlue giving it these args.
// But for debugging, we can skip that assuming it's already been ran.
"{\"OCTOAPP_REPO_DIR\":\"/home/pi/octoeverywhere\",\"OCTOAPP_ENV\":\"/home/pi/octoeverywhere-env\",\"USERNAME\":\"pi\",\"USER_HOME\":\"/home/pi\",\"CMD_LINE_ARGS\":\"-debug -skipsudoactions -noatuoselect\"}"
"{\"OCTOAPP_REPO_DIR\":\"/home/pi/octoapp\",\"OCTOAPP_ENV\":\"/home/pi/octoapp-env\",\"USERNAME\":\"pi\",\"USER_HOME\":\"/home/pi\",\"CMD_LINE_ARGS\":\"-debug -skipsudoactions -noatuoselect\"}"
]
},
{
Expand All @@ -80,7 +80,7 @@
// The module requires this json object to be passed.
// Normally the install.sh script runs, ensure everything is installed, creates a virtural env, and then runs this modlue giving it these args.
// But for debugging, we can skip that assuming it's already been ran.
"{\"OCTOAPP_REPO_DIR\":\"/home/pi/octoeverywhere\",\"OCTOAPP_ENV\":\"/home/pi/octoeverywhere-env\",\"USERNAME\":\"pi\",\"USER_HOME\":\"/home/pi\",\"CMD_LINE_ARGS\":\"-debug -skipsudoactions -observer\"}"
"{\"OCTOAPP_REPO_DIR\":\"/home/pi/octoapp\",\"OCTOAPP_ENV\":\"/home/pi/octoapp-env\",\"USERNAME\":\"pi\",\"USER_HOME\":\"/home/pi\",\"CMD_LINE_ARGS\":\"-debug -skipsudoactions -observer\"}"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
"Octo",
"octoclients",
"octoclientws",
"octoeverywhere",
"octoeverywhereimpl",
"octoapp",
"octoappimpl",
"octoflatbuffers",
"octoheaderimpl",
"octohttprequest",
Expand Down
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.md
recursive-include octoprint_octoeverywhere/templates *
recursive-include octoprint_octoeverywhere/translations *
recursive-include octoprint_octoeverywhere/static *
recursive-include octoprint_octoapp/templates *
recursive-include octoprint_octoapp/translations *
recursive-include octoprint_octoapp/static *
11 changes: 4 additions & 7 deletions developer/devnotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
- Use F5 to debug and run


## Install Other Branches:
- https://github.com/QuinnDamerell/OctoPrint-OctoEverywhere/archive/ui.zip

## Before checking in:
- Run in py2 env
- Run in py3 env
Expand All @@ -47,7 +44,7 @@
# Plugin Development Details


This repo contains code shared by both OctoPrint and Moonraker. Ideally most of the logic lives in the octoeverywhere module, and thus is shared. Any code that's specific to Moonraker or OctoPrint, is found in the octoprint_ or moonraker_ modules.
This repo contains code shared by both OctoPrint and Moonraker. Ideally most of the logic lives in the octoapp module, and thus is shared. Any code that's specific to Moonraker or OctoPrint, is found in the octoprint_ or moonraker_ modules.

## Major OctoPrint and Moonraker Differences

Expand All @@ -61,7 +58,7 @@ OctoPrint installs and sets up the plugin using the setup.py file. The setup pro

Moonraker currently requires the user to do a more advance setup. Either the user is required to ssh into the device, clone the repo, and then run the install script, or a tool like KIAUH can be used.

The install script must manually install all required system and python packages. It also must figure out the current Moonraker, Mailsail, crowsnest, and Fluidd configs to create the OctoEverywhere config. Finally must setup and run the systemd service that will run the OctoEverywhere host.
The install script must manually install all required system and python packages. It also must figure out the current Moonraker, Mailsail, crowsnest, and Fluidd configs to create the OctoApp config. Finally must setup and run the systemd service that will run the OctoApp host.

### OctoPrint Update

Expand All @@ -75,8 +72,8 @@ On update, the repo is pulled to the head of the branch. The install.sh script i

### OctoPrint Host

OctoPrint hosts our plugin in the same process. The octoprint_octoeverywhere module has all of the required files and extensions that OctoPrint requires. Since we are hosted in OctoPrint, we have to share the process, but we also get a lot of runtime nice things for free.
OctoPrint hosts our plugin in the same process. The octoprint_octoapp module has all of the required files and extensions that OctoPrint requires. Since we are hosted in OctoPrint, we have to share the process, but we also get a lot of runtime nice things for free.

### Moonraker Host

For moonraker, we aren't in process, we run as our own service. The moonraker_octoeverywhere module is responsible for setting up the environment required, and hosting the common OctoEverywhere logic.
For moonraker, we aren't in process, we run as our own service. The moonraker_octoapp module is responsible for setting up the environment required, and hosting the common OctoApp logic.
6 changes: 3 additions & 3 deletions developer/runpylint.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
REM This is just for local dev help, the github workflow does the real checkin linting.
pylint ..\octoeverywhere\
pylint ..\octoprint_octoeverywhere\
pylint ..\moonraker_octoeverywhere\
pylint ..\octoapp\
pylint ..\octoprint_octoapp\
pylint ..\moonraker_octoapp\
8 changes: 4 additions & 4 deletions developer/runpylint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cd ..
echo "Testing OctoEverywhere Module..."
pylint ./octoeverywhere/
echo "Testing OctoApp Module..."
pylint ./octoapp/
echo "Testing OctoPrint Module..."
pylint ./octoprint_octoeverywhere/
pylint ./octoprint_octoapp/
echo "Testing Moonraker Module..."
pylint ./moonraker_octoeverywhere/
pylint ./moonraker_octoapp/
echo "Testing Moonraker Installer Module..."
pylint ./moonraker_installer/
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ ensure_creality_os_right_repo_path()
return
else
log_info "Current path $OCTOAPP_REPO_DIR"
log_error "For the Creality devices the OctoEverywhere repo must be cloned into $HOME/octoapp"
log_error "For the Creality devices the OctoApp repo must be cloned into $HOME/octoapp"
log_important "Moving the repo and running the install again..."
cd $HOME
# Send errors to null, if the folder already exists this will fail.
Expand Down
2 changes: 1 addition & 1 deletion moonraker_installer/Discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _K1FindAllServiceFilesAndPairings(self, context:Context):
Logger.Header("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
Logger.Error( " Moonraker Not Found! ")
Logger.Warn( " The K1 and K1 Max don't have Moonraker or a web frontend installed by default. ")
Logger.Warn( " Moonraker and a frontend like Fluidd or Mainsail are required for OctoEverywhere. ")
Logger.Warn( " Moonraker and a frontend like Fluidd or Mainsail are required for OctoApp. ")
Logger.Blank()
Logger.Purple(" We have a step-by-step tutorial on how to install them in 30 seconds. ")
Logger.Purple(" Follow this link: https://oe.ink/s/k1 ")
Expand Down
12 changes: 6 additions & 6 deletions moonraker_installer/Service.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,27 @@ def _InstallK1(self, context:Context, argsJsonBase64):
# But, to launch our service, we have to use the py module run, which requires a environment var to be
# set for PYTHONPATH. The command can't set the env, so we write this script to our store, where we then run
# the service from.
runScriptFilePath = os.path.join(context.LocalFileStorageFolder, "run-octoeverywhere-service.sh")
runScriptFilePath = os.path.join(context.LocalFileStorageFolder, "run-octoapp-service.sh")
runScriptContents = f'''\
#!/bin/sh
#
# Runs OctoEverywhere service on the K1 and K1 max.
# Runs OctoApp service on the K1 and K1 max.
# The start-stop-daemon can't handle setting env vars, but the python module run command needs PYTHONPATH to be set
# to find the module correctly. Thus we point the service to this script, which sets the env and runs py.
#
# Don't edit this script, it's generated by the ./install.sh script during the OE install and update..
#
PYTHONPATH={context.RepoRootFolder} {context.VirtualEnvPath}/bin/python3 -m moonraker_octoeverywhere "{argsJsonBase64}"
PYTHONPATH={context.RepoRootFolder} {context.VirtualEnvPath}/bin/python3 -m moonraker_octoapp "{argsJsonBase64}"
exit $?
'''
# Write the required service file, make it point to our run script.
serviceFileContents = '''\
#!/bin/sh
#
# Starts OctoEverywhere service.
# Starts OctoApp service.
#
PID_FILE=/var/run/octoeverywhere.pid
PID_FILE=/var/run/octoapp.pid
start() {
HOME=/root start-stop-daemon -S -q -b -m -p $PID_FILE --exec '''+runScriptFilePath+'''
Expand Down Expand Up @@ -233,7 +233,7 @@ def RestartK1Service(serviceFilePath:str, throwOnBadReturnCode = True):
# Using this start-stop-daemon system, if we issue too many start, stop, restarts in quickly, the PID file gets out of
# sync and multiple process can spawn. That's bad because the websockets will disconnect each other.
# So we will run this run command to ensure that all of the process are dead, before we start a new one.
Util.RunShellCommand("ps -ef | grep 'moonraker_octoeverywhere' | grep -v grep | awk '{print $1}' | xargs -r kill -9", throwOnBadReturnCode)
Util.RunShellCommand("ps -ef | grep 'moonraker_octoapp' | grep -v grep | awk '{print $1}' | xargs -r kill -9", throwOnBadReturnCode)
Util.RunShellCommand(f"{serviceFilePath} start", throwOnBadReturnCode)


Expand Down
34 changes: 17 additions & 17 deletions moonraker_installer/Uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def DoUninstall(self, context:Context):

Logger.Blank()
Logger.Blank()
Logger.Header("You're about to uninstall OctoEverywhere.")
Logger.Header("You're about to uninstall OctoApp.")
Logger.Info ("This printer ID will be deleted, but you can always reinstall the plugin and re-add this printer.")
Logger.Blank()
r = input("Are you want to uninstall? [y/n]")
Expand All @@ -25,7 +25,7 @@ def DoUninstall(self, context:Context):
return
Logger.Blank()
Logger.Blank()
Logger.Header("Starting OctoEverywhere uninstall")
Logger.Header("Starting OctoApp uninstall")

# Since all service names must use the same identifier in them, we can find any services using the same search.
foundOeServices = []
Expand Down Expand Up @@ -56,7 +56,7 @@ def DoUninstall(self, context:Context):
Logger.Debug(f"Full service path: {serviceFilePath}")
Logger.Info(f"Stopping and deleting {serviceFileName}...")
Util.RunShellCommand(f"{serviceFilePath} stop", False)
Util.RunShellCommand("ps -ef | grep 'moonraker_octoeverywhere' | grep -v grep | awk '{print $1}' | xargs -r kill -9", False)
Util.RunShellCommand("ps -ef | grep 'moonraker_octoapp' | grep -v grep | awk '{print $1}' | xargs -r kill -9", False)
os.remove(serviceFilePath)
elif context.OsType == OsTypes.Debian:
Logger.Info(f"Stopping and deleting {serviceFileName}...")
Expand All @@ -73,7 +73,7 @@ def DoUninstall(self, context:Context):
Logger.Blank()
Logger.Blank()
Logger.Header("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
Logger.Info( " OctoEverywhere Uninstall Complete ")
Logger.Info( " OctoApp Uninstall Complete ")
Logger.Info( " We will miss you, please come back anytime! ")
Logger.Header("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
Logger.Blank()
Expand All @@ -84,23 +84,23 @@ def DoUninstall(self, context:Context):
# There's only one instance of moonraker, so there's no need to worry about multiple setups.
def DoK1FileCleanup(self):
# In modern setups, the env is here. In very few early installs, it's in /usr/share
self.DeleteDirOrFileIfExists("/usr/data/octoeverywhere-env")
self.DeleteDirOrFileIfExists("/usr/share/octoeverywhere-env")
self.DeleteDirOrFileIfExists("/usr/data/octoapp-env")
self.DeleteDirOrFileIfExists("/usr/share/octoapp-env")

# For all installs, the storage folder will be here
self.DeleteDirOrFileIfExists("/usr/data/printer_data/octoeverywhere-store")
self.DeleteDirOrFileIfExists("/usr/data/printer_data/octoapp-store")
# Delete any log files we have, there might be some rolling backups.
self.DeleteAllFilesContaining("/usr/data/printer_data/logs", "octoeverywhere")
self.DeleteAllFilesContaining("/usr/data/printer_data/logs", "octoapp")
# Delete any config files.
self.DeleteAllFilesContaining("/usr/data/printer_data/config", "octoeverywhere")
self.DeleteAllFilesContaining("/usr/data/printer_data/config", "octoapp")
# Remove our system config file include in the moonraker file, if there is one.
self.RemoveOctoEverywhereSystemCfgInclude("/usr/data/printer_data/config/moonraker.conf")
self.RemoveOctoAppSystemCfgInclude("/usr/data/printer_data/config/moonraker.conf")
# Delete the installer file if it's still there
self.DeleteDirOrFileIfExists("/usr/data/octoeverywhere-installer.log")
self.DeleteDirOrFileIfExists("/usr/data/octoapp-installer.log")

# Finally, remove the repo root. Note that /usr/share was used in very few early installs.
self.DeleteDirOrFileIfExists("/usr/data/octoeverywhere")
self.DeleteDirOrFileIfExists("/usr/share/octoeverywhere")
self.DeleteDirOrFileIfExists("/usr/data/octoapp")
self.DeleteDirOrFileIfExists("/usr/share/octoapp")


# Deletes a file or directory, if it exists.
Expand Down Expand Up @@ -133,16 +133,16 @@ def DeleteAllFilesContaining(self, path:str, searchStr:str):
Logger.Error(f"DeleteAllFilesContaining failed to delete {path} - {e}")


# Deletes the octoEverywhere-system.cfg file include if it exists in the moonraker config.
def RemoveOctoEverywhereSystemCfgInclude(self, moonrakerConfigPath:str):
# Deletes the octoapp-system.cfg file include if it exists in the moonraker config.
def RemoveOctoAppSystemCfgInclude(self, moonrakerConfigPath:str):
try:
Logger.Debug(f"Looking for OE system config include in {moonrakerConfigPath}")
output = []
lineFound = False
with open(moonrakerConfigPath, encoding="utf-8") as f:
lines = f.readlines()
for l in lines:
if "octoeverywhere-system.cfg" in l.lower():
if "octoapp-system.cfg" in l.lower():
lineFound = True
else:
output.append(l)
Expand All @@ -156,6 +156,6 @@ def RemoveOctoEverywhereSystemCfgInclude(self, moonrakerConfigPath:str):
for o in output:
f.write(f"{o}")

Logger.Debug(f"Removed octoeverywhere system config from {moonrakerConfigPath}")
Logger.Debug(f"Removed octoapp system config from {moonrakerConfigPath}")
except Exception as e:
Logger.Error(f"DeleteAllFilesContaining failed to delete {moonrakerConfigPath} - {e}")
2 changes: 1 addition & 1 deletion moonraker_octoapp/moonrakerclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def _AfterOpenReadyWaiter(self, targetWsObjRef):
"client_name": "OctoApp",
"version": self.PluginVersionStr,
"type": "agent", # We must be the agent type so that we can send agent-event, aka send messages to the UI.
"url": "https://octoeverywhere.com",
"url": "https://octoapp.eu",
}
if self.MoonrakerApiKey is not None:
Sentry.Info("Client", "API key added to websocket identify message.")
Expand Down
4 changes: 2 additions & 2 deletions moonraker_octoapp/systemconfigmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class SystemConfigManager:

# This can't change or it will break old installs.
c_updateConfigFileName = "octoeverywhere-system.cfg"
c_updateConfigFileName = "octoapp-system.cfg"

# We use config files to integrate into moonraker's update manager, which allows our plugin repo to stay updated.
# This also write a block that's used to allow the announcement system to show updates from our repo.
Expand All @@ -26,7 +26,7 @@ def EnsureUpdateManagerFilesSetup(klipperConfigDir, serviceName, pyVirtEnvRoot,
# Using `channel: beta` makes moonraker only update to the lasted tagged commit on the branch. Which lets us control releases.
channel: beta
path: {RepoRootFolder}
origin: https://github.com/QuinnDamerell/OctoPrint-OctoApp.git
origin: https://github.com/crysxd/OctoApp-Plugin.git
env: {pyVirtEnvRoot}/bin/python
requirements: requirements.txt
install_script: install.sh
Expand Down
2 changes: 1 addition & 1 deletion octoapp/compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Some of the features we need to integrate into the octoeverywhere package only exist on
# Some of the features we need to integrate into the octoapp package only exist on
# some platforms. This is basically an interface that allows us to dynamically control
# if some objects are available depending on the platform.
class Compat:
Expand Down
2 changes: 1 addition & 1 deletion octoapp/gadget.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, logger:logging.Logger, notificationHandler, printerStateInter
self.PrinterStateInterface = printerStateInterface
self.Lock = threading.Lock()
self.Timer = None
self.DefaultProtocolAndDomain = "https://gadget-v1-oeapi.octoeverywhere.com"
self.DefaultProtocolAndDomain = "http://127.0.0.1:4500"
self.FailedConnectionAttempts = 0

# If there is a current host lock, this is the hostname.
Expand Down
Loading

0 comments on commit 1fb16e0

Please sign in to comment.