Skip to content

Commit

Permalink
1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sourabh912 committed Jun 10, 2016
2 parents f492883 + 73af34e commit 259b806
Show file tree
Hide file tree
Showing 11 changed files with 636 additions and 52 deletions.
15 changes: 12 additions & 3 deletions bin/qds.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from qds_sdk.app import AppCmdLine
from qds_sdk.nezha import NezhaCmdLine
from qds_sdk.user import UserCmdLine
from qds_sdk.template import TemplateCmdLine

import os
import sys
Expand Down Expand Up @@ -78,6 +79,8 @@
" action --help\n"
"\nScheduler subcommand:\n"
" scheduler --help\n"
"\nTemplate subcommand:\n"
" template --help\n"
"\nAccount subcommand:\n"
" account --help\n"
"\nNezha subcommand:\n"
Expand Down Expand Up @@ -474,8 +477,12 @@ def nezhamain(args):
result = NezhaCmdLine.run(args)
print(result)

def main():
def templatemain(args):
result = TemplateCmdLine.run(args)
print(result)


def main():
optparser = OptionParser(usage=usage_str)
optparser.add_option("--token", dest="api_token",
default=os.getenv('QDS_API_TOKEN'),
Expand Down Expand Up @@ -508,7 +515,7 @@ def main():

optparser.disable_interspersed_args()
(options, args) = optparser.parse_args()

if options.chatty:
logging.basicConfig(level=logging.DEBUG)
elif options.verbose:
Expand Down Expand Up @@ -581,11 +588,13 @@ def main():

if a0 == "user":
return usermain(args)
if a0 == "template":
return templatemain(args)

cmdset = set(CommandClasses.keys())
sys.stderr.write("First command must be one of <%s>\n" %
"|".join(cmdset.union(["cluster", "action", "scheduler", "report",
"dbtap", "role", "group", "app", "account", "nezha", "user"])))
"dbtap", "role", "group", "app", "account", "nezha", "user", "template"])))
usage(optparser)


Expand Down
10 changes: 9 additions & 1 deletion qds_sdk/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class HiveCommand(Command):

optparser.add_option("--print-logs", action="store_true", dest="print_logs",
default=False, help="Fetch logs and print them to stderr.")
optparser.add_option("--retry", dest="retry", default=0, choices=[1,2,3], help="Number of retries for a job")

@classmethod
def parse(cls, args):
Expand Down Expand Up @@ -418,6 +419,8 @@ class SparkCommand(Command):

optparser.add_option("--print-logs", action="store_true", dest="print_logs",
default=False, help="Fetch logs and print them to stderr.")
optparser.add_option("--retry", dest="retry", default=0, help="Number of retries")

@classmethod
def validate_program(cls, options):
bool_program = options.program is not None
Expand Down Expand Up @@ -573,6 +576,7 @@ class PrestoCommand(Command):

optparser.add_option("--print-logs", action="store_true", dest="print_logs",
default=False, help="Fetch logs and print them to stderr.")
optparser.add_option("--retry", dest="retry", default=0, choices=[1,2,3], help="Number of retries for a job")

@classmethod
def parse(cls, args):
Expand Down Expand Up @@ -646,6 +650,7 @@ class HadoopCommand(Command):

optparser.add_option("--print-logs", action="store_true", dest="print_logs",
default=False, help="Fetch logs and print them to stderr.")
optparser.add_option("--retry", dest="retry", default=0, choices=[1,2,3], help="Number of retries for a job")

optparser.disable_interspersed_args()

Expand Down Expand Up @@ -689,7 +694,7 @@ def parse(cls, args):
"|".join(cls.subcmdlist))

parsed["sub_command"] = subcmd
parsed["sub_command_args"] = " ".join("'" + a + "'" for a in args)
parsed["sub_command_args"] = " ".join("'" + str(a) + "'" for a in args)

return parsed

Expand Down Expand Up @@ -816,6 +821,7 @@ class PigCommand(Command):

optparser.add_option("--print-logs", action="store_true", dest="print_logs",
default=False, help="Fetch logs and print them to stderr.")
optparser.add_option("--retry", dest="retry", choices=[1,2,3], default=0, help="Number of retries for a job")

@classmethod
def parse(cls, args):
Expand Down Expand Up @@ -931,6 +937,7 @@ class DbExportCommand(Command):

optparser.add_option("--print-logs", action="store_true", dest="print_logs",
default=False, help="Fetch logs and print them to stderr.")
optparser.add_option("--retry", dest="retry", default=0, choices=[1,2,3], help="Number of retries for a job")

@classmethod
def parse(cls, args):
Expand Down Expand Up @@ -1031,6 +1038,7 @@ class DbImportCommand(Command):

optparser.add_option("--print-logs", action="store_true", dest="print_logs",
default=False, help="Fetch logs and print them to stderr.")
optparser.add_option("--retry", dest="retry", default=0, choices=[1,2,3], help="Number of retries for a job")

@classmethod
def parse(cls, args):
Expand Down
4 changes: 2 additions & 2 deletions qds_sdk/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def list_instances(self, page=None, per_page=None):
if per_page is not None:
page_attr.append("per_page=%s" % per_page)
if page_attr:
url_path = "%s/instances?%s" % (self.element_path(args.id), "&".join(page_attr))
url_path = "%s/instances?%s" % (self.element_path(self.id), "&".join(page_attr))
#Todo Page numbers are thrown away right now
cmdjson = conn.get(url_path)
cmdlist = []
Expand All @@ -277,5 +277,5 @@ def list_instances(self, page=None, per_page=None):

def rerun(self, instance_id):
conn = Qubole.agent()
url_path = self.element_path(id) + "/instances/" + instance_id + "/rerun"
url_path = self.element_path(self.id) + "/instances/%s/rerun" % instance_id
return conn.post(url_path)['status']
Loading

0 comments on commit 259b806

Please sign in to comment.