From ecba6da2a9401d9134cf405dfab9e528941adc70 Mon Sep 17 00:00:00 2001 From: Iain Powrie Date: Fri, 14 Jan 2022 22:12:55 +0000 Subject: [PATCH 01/16] Add explicit collection of pytz to pipeline Diagnose module not found windows pyinstaller error --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 83e7283e..379f2447 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -120,6 +120,7 @@ win-dev-build: --hidden-import apscheduler --collect-all tzlocal --collect-all tzdata + --collect-all pytz artifacts: name: "crafty-${CI_RUNNER_TAGS}-${CI_COMMIT_BRANCH}_${CI_COMMIT_SHORT_SHA}" paths: @@ -158,6 +159,7 @@ win-prod-build: --hidden-import apscheduler --collect-all tzlocal --collect-all tzdata + --collect-all pytz artifacts: name: "crafty-${CI_RUNNER_TAGS}-${CI_COMMIT_BRANCH}_${CI_COMMIT_SHORT_SHA}" paths: From dde282d05ee308d54efa100bc37e7220fdf5b8f5 Mon Sep 17 00:00:00 2001 From: Iain Powrie Date: Fri, 14 Jan 2022 22:19:25 +0000 Subject: [PATCH 02/16] Change apscheduler back to collect-all in pipeline Diagnose module not found windows pyinstaller error --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 379f2447..31d6f645 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -117,7 +117,7 @@ win-dev-build: --paths .venv\Lib\site-packages --hidden-import cryptography --hidden-import cffi - --hidden-import apscheduler + --collect-all apscheduler --collect-all tzlocal --collect-all tzdata --collect-all pytz @@ -156,7 +156,7 @@ win-prod-build: --paths .venv\Lib\site-packages --hidden-import cryptography --hidden-import cffi - --hidden-import apscheduler + --collect-all apscheduler --collect-all tzlocal --collect-all tzdata --collect-all pytz From c7e72f953a7da7573c09e5e7d51da7edf1377f41 Mon Sep 17 00:00:00 2001 From: Iain Powrie Date: Fri, 14 Jan 2022 22:32:41 +0000 Subject: [PATCH 03/16] Copy metadata for the apscheduler and deps Still trying to diagnose pyinstaller hook issues, May add back collect-alls for tz --- .gitlab-ci.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 31d6f645..bdb85c08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -117,10 +117,8 @@ win-dev-build: --paths .venv\Lib\site-packages --hidden-import cryptography --hidden-import cffi + --recursive-copy-metadata apscheduler --collect-all apscheduler - --collect-all tzlocal - --collect-all tzdata - --collect-all pytz artifacts: name: "crafty-${CI_RUNNER_TAGS}-${CI_COMMIT_BRANCH}_${CI_COMMIT_SHORT_SHA}" paths: @@ -156,10 +154,9 @@ win-prod-build: --paths .venv\Lib\site-packages --hidden-import cryptography --hidden-import cffi + --recursive-copy-metadata apscheduler --collect-all apscheduler - --collect-all tzlocal - --collect-all tzdata - --collect-all pytz + artifacts: name: "crafty-${CI_RUNNER_TAGS}-${CI_COMMIT_BRANCH}_${CI_COMMIT_SHORT_SHA}" paths: From 00c7af8d8b3a34ac0524ea06627bbce42c698beb Mon Sep 17 00:00:00 2001 From: Iain Powrie Date: Fri, 14 Jan 2022 22:48:13 +0000 Subject: [PATCH 04/16] Add apscheduler sub-dep collect-alls back to pipe Diagnose module not found windows pyinstaller error --- .gitlab-ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bdb85c08..674d9257 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -117,8 +117,12 @@ win-dev-build: --paths .venv\Lib\site-packages --hidden-import cryptography --hidden-import cffi - --recursive-copy-metadata apscheduler --collect-all apscheduler + --collect-all tzlocal + --collect-all tzdata + --collect-all pytz + --collect-all six + artifacts: name: "crafty-${CI_RUNNER_TAGS}-${CI_COMMIT_BRANCH}_${CI_COMMIT_SHORT_SHA}" paths: @@ -154,8 +158,11 @@ win-prod-build: --paths .venv\Lib\site-packages --hidden-import cryptography --hidden-import cffi - --recursive-copy-metadata apscheduler --collect-all apscheduler + --collect-all tzlocal + --collect-all tzdata + --collect-all pytz + --collect-all six artifacts: name: "crafty-${CI_RUNNER_TAGS}-${CI_COMMIT_BRANCH}_${CI_COMMIT_SHORT_SHA}" From ccc41b7419349e2afabbe5d99f34fc655c87c754 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 14 Jan 2022 19:52:51 -0500 Subject: [PATCH 05/16] fix bug where crash detection was still using schedule --- app/classes/shared/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index ea4af70a..56b3faad 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -119,6 +119,8 @@ class Server: self.restart_count = 0 self.crash_watcher_schedule = None self.stats = stats + tz = get_localzone() + self.server_scheduler = BackgroundScheduler(timezone=str(tz)) self.backup_thread = threading.Thread(target=self.a_backup_server, daemon=True, name=f"backup_{self.name}") self.is_backingup = False @@ -144,8 +146,6 @@ class Server: logger.info("Scheduling server {} to start in {} seconds".format(self.name, delay)) console.info("Scheduling server {} to start in {} seconds".format(self.name, delay)) - tz = get_localzone() - self.server_scheduler = BackgroundScheduler(timezone=str(tz)) self.server_scheduler.add_job(self.run_scheduled_server, 'interval', seconds=delay, id=str(self.server_id)) self.server_scheduler.start() @@ -300,7 +300,7 @@ class Server: logger.info("Server {} has crash detection enabled - starting watcher task".format(self.name)) console.info("Server {} has crash detection enabled - starting watcher task".format(self.name)) - self.crash_watcher_schedule = schedule.every(30).seconds.do(self.detect_crash).tag(self.name) + self.crash_watcher_schedule = self.server_scheduler.add_job(self.detect_crash, 'interval', seconds=30, id="crash_watcher") def check_internet_thread(self, user_id, user_lang): if user_id: From 43a315874e0044ce6eb674e2ef70aa86ce16ce0c Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 14 Jan 2022 20:05:50 -0500 Subject: [PATCH 06/16] Fix player data bug --- app/classes/web/panel_handler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 07eb96c9..c6b4daa3 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -181,7 +181,10 @@ class PanelHandler(BaseHandler): except: data['stats']['waiting_start'] = False - page_data['num_players'] = 0 + try: + self.fetch_server_data(page_data) + except: + page_data['num_players'] = 0 IOLoop.current().add_callback(self.fetch_server_data, page_data) From 0e352029b832ca0919cc8a6f9879e6ccb0254856 Mon Sep 17 00:00:00 2001 From: Iain Powrie Date: Sat, 15 Jan 2022 02:21:06 +0000 Subject: [PATCH 07/16] Apply fix for pyinstaller apscheduler import --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 674d9257..1996376a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -117,7 +117,7 @@ win-dev-build: --paths .venv\Lib\site-packages --hidden-import cryptography --hidden-import cffi - --collect-all apscheduler + --hidden-import apscheduler --collect-all tzlocal --collect-all tzdata --collect-all pytz @@ -158,7 +158,7 @@ win-prod-build: --paths .venv\Lib\site-packages --hidden-import cryptography --hidden-import cffi - --collect-all apscheduler + --hidden-import apscheduler --collect-all tzlocal --collect-all tzdata --collect-all pytz From 50a6c0a2ce483abfa83b1df5432e35cdcf152980 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 14 Jan 2022 21:32:26 -0500 Subject: [PATCH 08/16] donwngrade tzlocal from 4.1 to 3.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 77b89f43..3466dd76 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,4 @@ tornado~=6.0 cached_property==1.5.2 apscheduler~=3.8.1 cron-validator~=1.0.3 -tzlocal~=4.1 \ No newline at end of file +tzlocal==3.0 \ No newline at end of file From cae2b8a35c23c954b6964f61a05709ff825de3e3 Mon Sep 17 00:00:00 2001 From: Iain Powrie Date: Sat, 15 Jan 2022 04:36:08 +0000 Subject: [PATCH 09/16] Attempt to fix pip backtracking through versions. Pipelines are stalling and failing. --- requirements.txt | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3466dd76..4e0f8c44 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,18 @@ -cryptography~=3.4 -argon2-cffi~=20.1 -bleach~=3.1 -colorama~=0.4 -cryptography~=3.4 -libgravatar~=1.0.0 -peewee~=3.13 -pexpect~=4.8 -psutil~=5.7 -pyOpenSSL~=19.1.0 +cryptography==3.4 +argon2-cffi==20.1 +bleach==3.1 +colorama==0.4 +cryptography==3.4 +libgravatar==1.0.0 +peewee==3.13 +pexpect==4.8 +psutil==5.7 +pyOpenSSL==19.1.0 PyYAML==5.3.1 -requests~=2.26 -termcolor~=1.1 -tornado~=6.0 +requests==2.26 +termcolor==1.1 +tornado==6.0 cached_property==1.5.2 -apscheduler~=3.8.1 -cron-validator~=1.0.3 -tzlocal==3.0 \ No newline at end of file +apscheduler==3.8.1 +cron-validator==1.0.3 +tzlocal==3.0 From 0d3fc439310a807b28bece9c33ae5238ab2be37d Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 14 Jan 2022 23:53:44 -0500 Subject: [PATCH 10/16] Remove schedules from DB when deleting a server. Add better messaging for support log prep. Add english translation for notify. Chnage dep to 4.0 for tzlocal --- app/classes/shared/tasks.py | 8 +++++++- app/classes/web/ajax_handler.py | 20 +++++++++++++++++++ app/classes/web/panel_handler.py | 22 -------------------- app/frontend/templates/base.html | 19 +++++++++++++++--- app/frontend/templates/notify.html | 6 +++--- app/translations/en_EN.json | 9 ++++++++- requirements.txt | 32 +++++++++++++++--------------- 7 files changed, 70 insertions(+), 46 deletions(-) diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index efc9e4a5..2bac6061 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -197,13 +197,19 @@ class TasksManager: for item in jobs: logger.info("JOB: {}".format(item)) + def remove_all_server_tasks(self, server_id): + schedules = management_helper.get_schedules_by_server(server_id) + for schedule in schedules: + self.remove_job(schedule.schedule_id) + def remove_job(self, sch_id): job = management_helper.get_scheduled_task_model(sch_id) management_helper.delete_scheduled_task(sch_id) if job.enabled: self.scheduler.remove_job(str(sch_id)) + logger.info("Job with ID {} was deleted.".format(sch_id)) else: - logger.info("Job with ID {} was deleted from DB, but was not enabled. Not going to try removing something that doesn't exist from active schedules.") + logger.info("Job with ID {} was deleted from DB, but was not enabled. Not going to try removing something that doesn't exist from active schedules.".format(sch_id)) def update_job(self, sch_id, job_data): management_helper.update_scheduled_task(sch_id, job_data) diff --git a/app/classes/web/ajax_handler.py b/app/classes/web/ajax_handler.py index f05bba3b..0686b9e0 100644 --- a/app/classes/web/ajax_handler.py +++ b/app/classes/web/ajax_handler.py @@ -407,6 +407,16 @@ class AjaxHandler(BaseHandler): server_id = self.get_argument('id', None) logger.info( "Removing server from panel for server: {}".format(self.controller.servers.get_server_friendly_name(server_id))) + + server_data = self.controller.get_server_data(server_id) + server_name = server_data['server_name'] + + self.controller.management.add_to_audit_log(exec_user_id, + "Deleted server {} named {}".format(server_id, server_name), + server_id, + self.get_remote_ip()) + + self.tasks_manager.remove_all_server_tasks(server_id) self.controller.remove_server(server_id, False) elif page == "delete_server_files": @@ -417,6 +427,16 @@ class AjaxHandler(BaseHandler): server_id = self.get_argument('id', None) logger.info( "Removing server and all associated files for server: {}".format(self.controller.servers.get_server_friendly_name(server_id))) + + server_data = self.controller.get_server_data(server_id) + server_name = server_data['server_name'] + + self.controller.management.add_to_audit_log(exec_user_id, + "Deleted server {} named {}".format(server_id, server_name), + server_id, + self.get_remote_ip()) + + self.tasks_manager.remove_all_server_tasks(server_id) self.controller.remove_server(server_id, True) @tornado.web.authenticated diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index c6b4daa3..3cd4150d 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -126,28 +126,6 @@ class PanelHandler(BaseHandler): elif page == 'contribute': template = "panel/contribute.html" - elif page == "remove_server": - server_id = self.get_argument('id', None) - - if not exec_user['superuser']: - self.redirect("/panel/error?error=Unauthorized access: not superuser") - return - elif server_id is None: - self.redirect("/panel/error?error=Invalid Server ID") - return - - server_data = self.controller.get_server_data(server_id) - server_name = server_data['server_name'] - - self.controller.management.add_to_audit_log(exec_user_data['user_id'], - "Deleted server {} named {}".format(server_id, server_name), - server_id, - self.get_remote_ip()) - - self.controller.remove_server(server_id) - self.redirect("/panel/dashboard") - return - elif page == 'dashboard': if exec_user['superuser'] == 1: try: diff --git a/app/frontend/templates/base.html b/app/frontend/templates/base.html index cf1e7347..ab6d5656 100644 --- a/app/frontend/templates/base.html +++ b/app/frontend/templates/base.html @@ -21,6 +21,7 @@ + @@ -139,7 +140,6 @@ {% block js %} diff --git a/app/frontend/templates/notify.html b/app/frontend/templates/notify.html index 4bb76b6e..2431c40a 100644 --- a/app/frontend/templates/notify.html +++ b/app/frontend/templates/notify.html @@ -29,11 +29,11 @@ {% end %}

Email: {{ data['user_data']['email'] }}

- Support Logs + {{ translate('notify', 'supportLogs', data['lang']) }} {% if "Super User" in data['user_role'] %} - Activity + {{ translate('notify', 'activityLog', data['lang']) }} {% end %} - Sign Out + {{ translate('notify', 'logout', data['lang']) }} \ No newline at end of file diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index 549097ec..0aa583bd 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -180,7 +180,14 @@ "cannotSee": "Not seeing everything?", "cannotSeeOnMobile": "Try clicking on a scheduled task for full details." }, - + "notify":{ + "supportLogs": "Support Logs", + "activityLog": "Activity Logs", + "logout": "Logout", + "preparingLogs": " Please wait while we prepare your logs... We`ll send a notification when they`re ready. This may take a while for large deployments.", + "downloadLogs": "Download Support Logs?", + "finishedPreparing": "We've finished preparing your support logs. Please click download to download" + }, "serverBackups": { "backupNow": "Backup Now!", "backupAtMidnight": "Auto-backup at midnight?", diff --git a/requirements.txt b/requirements.txt index 3466dd76..f21e1bb9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,18 @@ -cryptography~=3.4 -argon2-cffi~=20.1 -bleach~=3.1 -colorama~=0.4 -cryptography~=3.4 -libgravatar~=1.0.0 -peewee~=3.13 -pexpect~=4.8 -psutil~=5.7 -pyOpenSSL~=19.1.0 +cryptography==3.4 +argon2-cffi==20.1 +bleach==3.1 +colorama==0.4 +cryptography==3.4 +libgravatar==1.0.0 +peewee==3.13 +pexpect==4.8 +psutil==5.7 +pyOpenSSL==19.1.0 PyYAML==5.3.1 -requests~=2.26 -termcolor~=1.1 -tornado~=6.0 +requests==2.26 +termcolor==1.1 +tornado==6.0 cached_property==1.5.2 -apscheduler~=3.8.1 -cron-validator~=1.0.3 -tzlocal==3.0 \ No newline at end of file +apscheduler==3.8.1 +cron-validator==1.0.3 +tzlocal==4.0 \ No newline at end of file From 0d8ff36fe4a4cd902b17042f983f7104b3b6f599 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 15 Jan 2022 00:58:17 -0500 Subject: [PATCH 11/16] fix windows path escaping --- app/classes/shared/main_controller.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 8e1615aa..89686455 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -134,7 +134,6 @@ class Controller: def package_support_logs(self, exec_user): - time.sleep(5) websocket_helper.broadcast_user(exec_user['user_id'], 'notification', 'Preparing your support logs') tempDir = tempfile.mkdtemp() tempZipStorage = tempfile.mkdtemp() @@ -254,6 +253,8 @@ class Controller: server_file = "{server}-{version}.jar".format(server=server, version=version) full_jar_path = os.path.join(server_dir, server_file) + if helper.is_os_windows(): + full_jar_path.replace(' ', '^ ') # make the dir - perhaps a UUID? helper.ensure_dir_exists(server_dir) @@ -324,6 +325,9 @@ class Controller: f.close() full_jar_path = os.path.join(new_server_dir, server_jar) + if helper.is_os_windows(): + full_jar_path.replace(' ', '^ ') + server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), full_jar_path) @@ -357,6 +361,9 @@ class Controller: f.close() full_jar_path = os.path.join(new_server_dir, server_jar) + if helper.is_os_windows(): + full_jar_path.replace(' ', '^ ') + server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), full_jar_path) From e6000577b357eb55d1ea1f2271c6d70c1c499321 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 15 Jan 2022 01:21:04 -0500 Subject: [PATCH 12/16] Tryin something for windows --- app/classes/shared/main_controller.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 89686455..a42da52c 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -255,6 +255,7 @@ class Controller: full_jar_path = os.path.join(server_dir, server_file) if helper.is_os_windows(): full_jar_path.replace(' ', '^ ') + full_jar_path = helper.wtol_path(full_jar_path) # make the dir - perhaps a UUID? helper.ensure_dir_exists(server_dir) @@ -327,7 +328,8 @@ class Controller: full_jar_path = os.path.join(new_server_dir, server_jar) if helper.is_os_windows(): full_jar_path.replace(' ', '^ ') - + full_jar_path = helper.wtol_path(full_jar_path) + server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), full_jar_path) @@ -363,6 +365,7 @@ class Controller: full_jar_path = os.path.join(new_server_dir, server_jar) if helper.is_os_windows(): full_jar_path.replace(' ', '^ ') + full_jar_path = helper.wtol_path(full_jar_path) server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), From ef19cecc27440209a78b466aa12529816ed3c26a Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 15 Jan 2022 01:30:33 -0500 Subject: [PATCH 13/16] hopeful fix for windows path bug --- app/classes/shared/main_controller.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index a42da52c..468f0579 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -250,12 +250,14 @@ class Controller: server_id = helper.create_uuid() server_dir = os.path.join(helper.servers_dir, server_id) backup_path = os.path.join(helper.backup_path, server_id) + if helper.is_os_windows(): + server_dir.replace(' ', '^ ') + backup_path.replace(' ', '^ ') + server_dir = helper.wtol_path(server_dir) + backup_path = helper.wtol_path(backup_path) server_file = "{server}-{version}.jar".format(server=server, version=version) full_jar_path = os.path.join(server_dir, server_file) - if helper.is_os_windows(): - full_jar_path.replace(' ', '^ ') - full_jar_path = helper.wtol_path(full_jar_path) # make the dir - perhaps a UUID? helper.ensure_dir_exists(server_dir) @@ -309,6 +311,11 @@ class Controller: server_id = helper.create_uuid() new_server_dir = os.path.join(helper.servers_dir, server_id) backup_path = os.path.join(helper.backup_path, server_id) + if helper.is_os_windows(): + new_server_dir.replace(' ', '^ ') + backup_path.replace(' ', '^ ') + server_dir = helper.wtol_path(new_server_dir) + backup_path = helper.wtol_path(backup_path) helper.ensure_dir_exists(new_server_dir) helper.ensure_dir_exists(backup_path) @@ -326,9 +333,6 @@ class Controller: f.close() full_jar_path = os.path.join(new_server_dir, server_jar) - if helper.is_os_windows(): - full_jar_path.replace(' ', '^ ') - full_jar_path = helper.wtol_path(full_jar_path) server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), @@ -344,6 +348,12 @@ class Controller: server_id = helper.create_uuid() new_server_dir = os.path.join(helper.servers_dir, server_id) backup_path = os.path.join(helper.backup_path, server_id) + if helper.is_os_windows(): + new_server_dir.replace(' ', '^ ') + backup_path.replace(' ', '^ ') + server_dir = helper.wtol_path(new_server_dir) + backup_path = helper.wtol_path(backup_path) + tempDir = helper.get_os_understandable_path(zip_path) helper.ensure_dir_exists(new_server_dir) helper.ensure_dir_exists(backup_path) @@ -363,9 +373,6 @@ class Controller: f.close() full_jar_path = os.path.join(new_server_dir, server_jar) - if helper.is_os_windows(): - full_jar_path.replace(' ', '^ ') - full_jar_path = helper.wtol_path(full_jar_path) server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), From a54fe49d84cfe4e1e3924309fbfb98e5da27dc9c Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 15 Jan 2022 01:37:44 -0500 Subject: [PATCH 14/16] Windows should work now --- app/classes/shared/main_controller.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 468f0579..5fb5fc35 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -251,10 +251,10 @@ class Controller: server_dir = os.path.join(helper.servers_dir, server_id) backup_path = os.path.join(helper.backup_path, server_id) if helper.is_os_windows(): - server_dir.replace(' ', '^ ') - backup_path.replace(' ', '^ ') server_dir = helper.wtol_path(server_dir) backup_path = helper.wtol_path(backup_path) + server_dir.replace(' ', '^ ') + backup_path.replace(' ', '^ ') server_file = "{server}-{version}.jar".format(server=server, version=version) full_jar_path = os.path.join(server_dir, server_file) @@ -312,10 +312,10 @@ class Controller: new_server_dir = os.path.join(helper.servers_dir, server_id) backup_path = os.path.join(helper.backup_path, server_id) if helper.is_os_windows(): - new_server_dir.replace(' ', '^ ') - backup_path.replace(' ', '^ ') server_dir = helper.wtol_path(new_server_dir) backup_path = helper.wtol_path(backup_path) + new_server_dir.replace(' ', '^ ') + backup_path.replace(' ', '^ ') helper.ensure_dir_exists(new_server_dir) helper.ensure_dir_exists(backup_path) @@ -349,10 +349,10 @@ class Controller: new_server_dir = os.path.join(helper.servers_dir, server_id) backup_path = os.path.join(helper.backup_path, server_id) if helper.is_os_windows(): + new_server_dir = helper.wtol_path(new_server_dir) + backup_path = helper.wtol_path(backup_path) new_server_dir.replace(' ', '^ ') backup_path.replace(' ', '^ ') - server_dir = helper.wtol_path(new_server_dir) - backup_path = helper.wtol_path(backup_path) tempDir = helper.get_os_understandable_path(zip_path) helper.ensure_dir_exists(new_server_dir) @@ -390,6 +390,9 @@ class Controller: old_bu_path = server_data['backup_path'] Server_Perms_Controller.backup_role_swap(old_server_id, new_server_id) backup_path = helper.validate_traversal(helper.backup_path, old_bu_path) + if helper.is_os_windows(): + backup_path = helper.wtol_path(backup_path) + backup_path.replace(' ', '^ ') backup_path_components = list(backup_path.parts) backup_path_components[-1] = new_uuid new_bu_path = pathlib.PurePath(os.path.join(*backup_path_components)) From 27bdce74e86226d295fcaa3dcc94ab1023aa84b0 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 15 Jan 2022 01:47:31 -0500 Subject: [PATCH 15/16] Fix windows execution paths --- app/classes/shared/main_controller.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 5fb5fc35..5a477bf0 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -280,7 +280,7 @@ class Controller: server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), - full_jar_path) + +'"'+full_jar_path+'"') server_log_file = "{}/logs/latest.log".format(server_dir) server_stop = "stop" @@ -336,7 +336,7 @@ class Controller: server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), - full_jar_path) + +'"'+full_jar_path+'"') server_log_file = "{}/logs/latest.log".format(new_server_dir) server_stop = "stop" @@ -376,7 +376,7 @@ class Controller: server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), - full_jar_path) + +'"'+full_jar_path+'"') logger.debug('command: ' + server_command) server_log_file = "{}/logs/latest.log".format(new_server_dir) server_stop = "stop" @@ -403,6 +403,7 @@ class Controller: def register_server(self, name: str, server_uuid: str, server_dir: str, backup_path: str, server_command: str, server_file: str, server_log_file: str, server_stop: str, server_port: int): # put data in the db + new_id = self.servers.create_server(name, server_uuid, server_dir, backup_path, server_command, server_file, server_log_file, server_stop, server_port) if not helper.check_file_exists(os.path.join(server_dir, "crafty_managed.txt")): try: From fefa6248b40dba6da732d6fdcee92b04a55b679d Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 15 Jan 2022 02:01:51 -0500 Subject: [PATCH 16/16] Remove time from cron dbs --- app/classes/web/panel_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 3cd4150d..540bc531 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1039,7 +1039,7 @@ class PanelHandler(BaseHandler): "interval": '', "command": '', #We'll base every interval off of a midnight start time. - "start_time": '00:00', + "start_time": '', "command": command, "cron_string": cron_string, "enabled": enabled, @@ -1159,7 +1159,7 @@ class PanelHandler(BaseHandler): "interval": '', "command": '', #We'll base every interval off of a midnight start time. - "start_time": '00:00', + "start_time": '', "command": command, "cron_string": cron_string, "enabled": enabled,