watch_build.add_argument("id", nargs=1, help=_("Build ID"))
watch_build.set_defaults(func=self.handle_watch_build)
+ # watch-job
+ watch_job = subparsers.add_parser("watch-job", help=_("Watch the status of a job"))
+ watch_job.add_argument("id", nargs=1, help=_("Job ID"))
+ watch_job.set_defaults(func=self.handle_watch_job)
+
return parser.parse_args()
def handle_build(self, ns):
def handle_watch_build(self, ns):
build = self.client.get_build(ns.id[0])
+ return self._watch_something(build)
+
+ def handle_watch_job(self, ns):
+ job = self.client.get_job(ns.id[0])
+
+ return self._watch_something(job)
+
+ def _watch_something(self, o):
while True:
- s = build.dump()
+ s = o.dump()
print(s)
- # Break the loop if the build is not active any more
+ # Break the loop if the build/job is not active any more
# (since we don't expect any changes)
- if not build.is_active():
+ if not o.is_active():
break
time.sleep(60)
"""
return self.hub.test()
+ # Builds
+
def create_build(self, filename, **kwargs):
build_id = self.hub.create_build(filename, **kwargs)
def get_build(self, build_id):
return Build(self, build_id)
+ # Jobs
+
+ def get_job(self, job_id):
+ return Job(self, job_id)
+
class _ClientObject(object):
def __init__(self, client, id):
def __lt__(self, other):
return self.arch < other.arch
+ @property
+ def name(self):
+ """
+ The name of this job
+ """
+ return self.data.get("name")
+
+ @property
+ def type(self):
+ """
+ The type of this build
+ """
+ return self.data.get("type")
+
@property
def arch(self):
"""
s.append(_("in %s") % format_time(self.duration))
return " ".join(s)
+
+ def dump(self):
+ s = []
+
+ # Name
+ s.append(self.name)
+
+ # Append tag for test buils
+ if self.type == "test":
+ s.append("[T]")
+
+ # UUID
+ s.append("(%s)" % self.id)
+
+ # Show the builder for active jobs
+ if self.is_active() and self.builder:
+ s.append(_("Builder: %s") % self.builder)
+
+ return " ".join(s)