Loading app/main.py +9 −3 Original line number Diff line number Diff line Loading @@ -55,18 +55,24 @@ class MyHandler(BaseHTTPRequestHandler): temp_file.flush() temp_file.close() ftp.close() stdin, stdout, stderr = ssh.exec_command('cat ' + temp_file_name + ' | /usr/local/bin/wrapper.sh') print(stdout.channel.recv_exit_status()) channel = ssh.exec_command('cat ' + temp_file_name + ' | /usr/local/bin/wrapper.sh') print(channel.read()) print(f'exit code: {channel.recv_exit_status()}') # TODO: check exit code, handle errors ssh.exec_command('rm ' + temp_file_name) # TODO: commented for now to check the file #ssh.exec_command('rm ' + temp_file_name) # Edit nextcloud account, set quota and email auth = HTTPBasicAuth(os.environ['NEXTCLOUD_ADMIN_USER'], os.environ['NEXTCLOUD_ADMIN_PASSWORD']) url = 'http://nextcloud/ocs/v1.php/cloud/users/' + target_email headers = {'OCS-APIRequest': 'true'} r = requests.put(url, data={'key': 'email', 'value': fallback_email}, headers=headers, auth=auth) print(r.text) print(f'status code: {r.status_code}') # TODO: check status code r = requests.put(url, data={'key': 'quota', 'value': nextcloud_quota}, headers=headers, auth=auth) print(r.text) print(f'status code: {r.status_code}') # TODO: check status code self.respond(200, "account created") Loading Loading
app/main.py +9 −3 Original line number Diff line number Diff line Loading @@ -55,18 +55,24 @@ class MyHandler(BaseHTTPRequestHandler): temp_file.flush() temp_file.close() ftp.close() stdin, stdout, stderr = ssh.exec_command('cat ' + temp_file_name + ' | /usr/local/bin/wrapper.sh') print(stdout.channel.recv_exit_status()) channel = ssh.exec_command('cat ' + temp_file_name + ' | /usr/local/bin/wrapper.sh') print(channel.read()) print(f'exit code: {channel.recv_exit_status()}') # TODO: check exit code, handle errors ssh.exec_command('rm ' + temp_file_name) # TODO: commented for now to check the file #ssh.exec_command('rm ' + temp_file_name) # Edit nextcloud account, set quota and email auth = HTTPBasicAuth(os.environ['NEXTCLOUD_ADMIN_USER'], os.environ['NEXTCLOUD_ADMIN_PASSWORD']) url = 'http://nextcloud/ocs/v1.php/cloud/users/' + target_email headers = {'OCS-APIRequest': 'true'} r = requests.put(url, data={'key': 'email', 'value': fallback_email}, headers=headers, auth=auth) print(r.text) print(f'status code: {r.status_code}') # TODO: check status code r = requests.put(url, data={'key': 'quota', 'value': nextcloud_quota}, headers=headers, auth=auth) print(r.text) print(f'status code: {r.status_code}') # TODO: check status code self.respond(200, "account created") Loading