Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be782642 authored by Felix Ableitner's avatar Felix Ableitner
Browse files

Log command output

parent cfc15736
Loading
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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")