def upload(self, file, port): self.delete_file() FileManager('/tmp').upload(file) log = getoutput('sh script/create_website.sh {} {}'.format( self.name, port)) print(log) execute('INSERT INTO NGINX (name, port) values (?, ?)', (self.name, port))
def select_cron(self): tasks = execute("SELECT * FROM crontab;") result = [] for i in tasks: nxt = "" for task in self.cron: if task.comment == str(i[0]): nxt = task.schedule(date_from=datetime.now()).get_next() result.append({ "next": nxt, "cron_id": i[0], "cron_type": i[1], "command": i[2], "description": i[3] }) return result
def get_web_list(): return execute('SELECT * FROM nginx')
def delete_file(self): getoutput('rm -rf /var/www/nginx/' + self.name) getoutput('rm -f /tmp/' + self.name + '.zip') getoutput('rm -f /etc/nginx/sites-enabled/' + self.name) getoutput('sudo nginx -s reload') execute('DELETE FROM nginx WHERE name = ?', (self.name, ))
def delete_cron(self, cron_id): execute("DELETE FROM crontab where cron_id = ?;", (cron_id,)) for task in self.cron: if task.comment == str(cron_id): self.cron.remove(task) self.cron.write()