Add unexecuted clear. Add option to compress backups

This commit is contained in:
Andrew 2022-03-02 12:55:49 -05:00
parent fec877db7b
commit 61ac97c02e
7 changed files with 45 additions and 2 deletions

View File

@ -389,5 +389,11 @@ class helpers_management:
else:
logger.debug(f"Not removing {dir_to_del} from excluded directories - not in the excluded directory list for server ID {server_id}")
@staticmethod
def clear_unexecuted_commands():
Commands.update({
Commands.executed: True
}).where(Commands.executed == False).execute()
management_helper = helpers_management()

View File

@ -481,8 +481,8 @@ class Helpers:
data = json.loads(file_data)
pid = data.get('pid')
started = data.get('started')
console.critical(f"Another Crafty Controller agent seems to be running...\npid: {pid} \nstarted on: {started}")
if psutil.pid_exists(pid):
console.critical(f"Another Crafty Controller agent seems to be running...\npid: {pid} \nstarted on: {started}")
logger.critical("Found running crafty process. Exiting.")
sys.exit(1)
else:

View File

@ -594,3 +594,6 @@ class Controller:
self.servers_list.pop(counter)
counter += 1
@staticmethod
def clear_unexecuted_commands():
helpers_management.clear_unexecuted_commands()

View File

@ -306,6 +306,11 @@ class AjaxHandler(BaseHandler):
self.controller.users.update_server_order(exec_user['user_id'], bleach.clean(self.get_argument('order')))
return
elif page == "clear_comms":
if exec_user['superuser']:
self.controller.clear_unexecuted_commands()
return
elif page == "kill":
if not permissions['Commands'] in user_perms:
if not superuser:

View File

@ -141,6 +141,21 @@
</div>
</div>
</div>
{% if data['superuser'] %}
<div class="row">
<div class="col-md-12 col-lg-12 grid-margin stretch-card">
<div class="card">
<div class="card-header header-sm d-flex justify-content-between align-items-center">
<h4 class="card-title"><i class="fas fa-user-tag"></i> {{ translate('panelConfig', 'adminControls', data['lang']) }}</h4>
</div>
<div class="card-body">
<button type="button" class="btn btn-outline-danger clear-comm">{{ translate('panelConfig', 'clearComms', data['lang']) }}</button>
</div>
</div>
</div>
</div>
{% end %}
</div>
</div>
</div>
@ -206,6 +221,17 @@ $( document ).ready(function() {
message: api_key,
});
});
$('.clear-comm').click(function () {
var token = getCookie("_xsrf")
$.ajax({
type: "POST",
headers: {'X-XSRFToken': token},
url: '/ajax/clear_comm',
success: function (data) {
},
});
})
</script>
{% end %}

View File

@ -357,7 +357,9 @@
"cancel": "Cancel",
"delete": "Delete",
"superConfirmTitle": "Enable superuser? Are you sure?",
"superConfirm": "Proceed only if you want this user to have access to EVERYTHING (all user accounts, servers, panel settings, etc.). They can even revoke your superuser rights."
"superConfirm": "Proceed only if you want this user to have access to EVERYTHING (all user accounts, servers, panel settings, etc.). They can even revoke your superuser rights.",
"adminControls": "Admin Controls",
"clearComms": "Clear Un-executed Commands"
},
"userConfig": {
"pageTitle": "Edit User",

View File

@ -150,6 +150,7 @@ if __name__ == '__main__':
project_root = os.path.dirname(__file__)
controller.set_project_root(project_root)
controller.clear_unexecuted_commands()
def sigterm_handler():
print() # for newline