Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@endpoint(api=True)
def handle_api_fs_finish_upload(self, http_context):
name = http_context.json_body()['name']
path = http_context.json_body()['path']
id = http_context.json_body()['id']
chunk_dir = '/tmp/upload-%s' % id
target = os.path.join(path, name.replace('/', ''))
with open(target, 'wb') as f:
for i in range(len(os.listdir(chunk_dir))):
f.write(open(os.path.join(chunk_dir, str(i + 1))).read())
shutil.rmtree(chunk_dir)
return target
@endpoint(api=True)
def handle_api_tz_set(self, http_context, tz=None):
return self.manager.set_tz(tz)
@endpoint(api=True)
def handle_api_get(self, http_context, manager_id=None, package_id=None):
return self.__package_to_json(self.managers[manager_id].get_package(package_id))
@endpoint(api=True)
def handle_api_config_get(self, http_context):
return self.manager.get_config()
@endpoint(api=True)
def handle_api_apply(self, http_context, manager_id=None):
mgr = self.managers[manager_id]
selection = json.loads(http_context.body)
cmd = mgr.get_apply_cmd(selection)
return {
'terminalCommand': cmd,
}
@endpoint(api=True)
def handle_api_uptime(self, http_context):
return time.time() - psutil.boot_time()
@endpoint(api=True)
def handle_api_tasks_request_update(self, http_context):
self.service.send_update()
@endpoint(api=True)
def handle_api_state(self, http_context, iface=None):
return self.manager.get_state(iface)
@endpoint(api=True)
def handle_api_config_set(self, http_context):
return self.manager.set_config(json.loads(http_context.body))
@endpoint(page=True, auth=False)
def handle_file(self, http_context, plugin=None, path=None):
if '..' in path:
return http_context.respond_not_found()
return http_context.file(PluginManager.get(aj.context).get_content_path(plugin, path))