Skip to content

Commit

Permalink
cli: add hql error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmoore committed Jun 4, 2019
1 parent 27bea9e commit f42d841
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions components/tools/OmeroPy/src/omero/plugins/hql.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ def _configure(self, parser):
parser.add_limit_arguments()
parser.add_style_argument()
parser.add_login_arguments()
self.add_error("NO_QUIET", 67,
"Can't ask for query with --quiet option")
self.add_error("NOT_ADMIN", 53,
("SecurityViolation: Current user is not an"
" admin and cannot use '--admin'"))
self.add_error("BAD_QUERY", 52, "Bad query: %s")

def __call__(self, args):
if args.query:
self.hql(args)
else:
if self.ctx.isquiet:
self.ctx.die(67, "Can't ask for query with --quiet option")
self.raise_error("NO_QUIET")
while True:
args.query = self.ctx.input("Enter query:")
if not args.query:
Expand Down Expand Up @@ -246,13 +252,12 @@ def project(self, querySvc, queryStr, params, ice_map):
return rv
except omero.SecurityViolation, sv:
if "omero.group" in ice_map:
self.ctx.die(53, "SecurityViolation: Current user is not an"
" admin and cannot use '--admin'")
self.raise_error("NOT_ADMIN")
else:
self.ctx.die(54, "SecurityViolation: %s" % sv)
except omero.QueryException, qe:
self.ctx.set("last.hql.rv", [])
self.ctx.die(52, "Bad query: %s" % qe.message)
self.raise_error("BAD_QUERY", qe.message)

try:
register("hql", HqlControl, HELP)
Expand Down

0 comments on commit f42d841

Please sign in to comment.