# #
###############################################################################
+import asyncio
import argparse
import os.path
import sys
# Call function
try:
- ret = args.func(client, args)
+ ret = asyncio.run(args.func(client, args))
# Catch invalid inputs
except ValueError as e:
# Return with exit code
sys.exit(ret or 0)
- def _build(self, client, ns):
+ async def _build(self, client, ns):
# Create a temporary directory.
temp_dir = tempfile.mkdtemp()
if os.path.exists(temp_dir):
shutil.rmtree(temp_dir, ignore_errors=True)
- def _check_connection(self, client, ns):
+ async def _check_connection(self, client, ns):
success = client.check_connection()
if success:
print("%s: %s" % (_("Connection OK"), success))
- def _upload(self, client, ns):
- for path in ns.file:
- client.upload_file(path)
+ async def _upload(self, client, ns):
+ for file in ns.file:
+ upload_id = await client.upload(file)
- def _watch_build(self, client, ns):
+ # Tell the user
+ print(_("%(file)s uploaded as %(id)s") % {
+ "file" : file,
+ "id" : upload_id,
+ }
+ )
+
+ async def _watch_build(self, client, ns):
build = client.get_build(ns.id[0])
return self._watch_something(build)
- def _watch_job(self, client, ns):
+ async def _watch_job(self, client, ns):
job = client.get_job(ns.id[0])
return self._watch_something(job)
- def _watch_something(self, o):
+ async def _watch_something(self, o):
while True:
s = o.dump()
print(s)