mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 05:05:19 +08:00
upload_log.py: add server as an argument (#25702)
This commit is contained in:
+7
-6
@@ -25,10 +25,6 @@ except ImportError as e:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
SERVER = 'https://logs.px4.io'
|
|
||||||
#SERVER = 'http://localhost:5006' # for testing locally
|
|
||||||
UPLOAD_URL = SERVER+'/upload'
|
|
||||||
|
|
||||||
quiet = False
|
quiet = False
|
||||||
|
|
||||||
def ask_value(text, default=None):
|
def ask_value(text, default=None):
|
||||||
@@ -60,6 +56,8 @@ def main():
|
|||||||
parser = ArgumentParser(description=__doc__)
|
parser = ArgumentParser(description=__doc__)
|
||||||
parser.add_argument('--quiet', '-q', dest='quiet', action='store_true', default=False,
|
parser.add_argument('--quiet', '-q', dest='quiet', action='store_true', default=False,
|
||||||
help='Quiet mode: do not ask for values which were not provided as parameters')
|
help='Quiet mode: do not ask for values which were not provided as parameters')
|
||||||
|
parser.add_argument('--server', dest='server', type=str, default='https://logs.px4.io',
|
||||||
|
help='Server URL (default: https://logs.px4.io), use http://localhost:5006 for testing locally')
|
||||||
parser.add_argument("--description", dest="description", type=str,
|
parser.add_argument("--description", dest="description", type=str,
|
||||||
help="Log description", default=None)
|
help="Log description", default=None)
|
||||||
parser.add_argument("--feedback", dest="feedback", type=str,
|
parser.add_argument("--feedback", dest="feedback", type=str,
|
||||||
@@ -99,6 +97,9 @@ def main():
|
|||||||
else:
|
else:
|
||||||
email = args.email
|
email = args.email
|
||||||
|
|
||||||
|
server = args.server
|
||||||
|
upload_url = server + '/upload'
|
||||||
|
|
||||||
payload = {'type': args.type, 'description': description,
|
payload = {'type': args.type, 'description': description,
|
||||||
'feedback': feedback, 'email': email, 'source': args.source}
|
'feedback': feedback, 'email': email, 'source': args.source}
|
||||||
|
|
||||||
@@ -113,13 +114,13 @@ def main():
|
|||||||
print('Uploading '+file_name+'...')
|
print('Uploading '+file_name+'...')
|
||||||
|
|
||||||
with open(file_name, 'rb') as f:
|
with open(file_name, 'rb') as f:
|
||||||
r = requests.post(UPLOAD_URL, data=payload, files={'filearg': f},
|
r = requests.post(upload_url, data=payload, files={'filearg': f},
|
||||||
allow_redirects=False)
|
allow_redirects=False)
|
||||||
if r.status_code == 302: # redirect
|
if r.status_code == 302: # redirect
|
||||||
if 'Location' in r.headers:
|
if 'Location' in r.headers:
|
||||||
plot_url = r.headers['Location']
|
plot_url = r.headers['Location']
|
||||||
if len(plot_url) > 0 and plot_url[0] == '/':
|
if len(plot_url) > 0 and plot_url[0] == '/':
|
||||||
plot_url = SERVER + plot_url
|
plot_url = server + plot_url
|
||||||
print('URL: '+plot_url)
|
print('URL: '+plot_url)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user