def run_command(self, *args, **kwargs): try: with suppress_stdout_stderr(): output = subprocess.check_output("/usr/local/bin/pip install git+https://[email protected]/buddyup/dewey.git#egg=dewey --upgrade", shell=True,) print("complete.") except subprocess.CalledProcessError as grepexc: print("\nError upgrading dewey. \n%s" % (grepexc.output,))
def run_command(self, *args, **kwargs): branch_name = self.get_branch_name(**kwargs) current_branch_cmd = "git rev-parse --abbrev-ref HEAD" current_branch = subprocess.check_output(current_branch_cmd, shell=True, ) puts("") puts(colored.green("Creating branch %s" % branch_name)) puts("") base_branch = self.question_with_default("What branch do you want to base the new branch on?", default="master") # Checkout master, check if it's behind, ask to pull puts("Verifying %s..." % base_branch) with indent(4): cmd = "git log %s..origin/%s --oneline" % (base_branch, base_branch) output = subprocess.check_output(cmd, shell=True, ) if output == "": puts("%s is up to date." % base_branch) else: puts("%s is behind origin." % base_branch) if self.answer_yes_or_no("Do you want to update it?" % base_branch): cmd = "git checkout %s; git pull; git checkout %s" % (base_branch, current_branch) with suppress_stdout_stderr(): output = subprocess.check_output(cmd, shell=True, ) puts("%s has been updated." % base_branch) else: puts("%s has been left alone." % base_branch) # Start a new branch called feature/foo cmd = "git checkout %s; git branch %s" % (base_branch, branch_name) with suppress_stdout_stderr(): output = subprocess.check_output(cmd, shell=True, ) puts("%s created." % branch_name) # Push it to github if self.answer_yes_or_no("Push to github?"): cmd = "git push -u origin %s" % (branch_name, ) with suppress_stdout_stderr(): output = subprocess.check_output(cmd, shell=True, ) puts("Pushed.")
def run_command(self, *args, **kwargs): self.ensure_dev_setup() try: puts("Upgrading dewey... ", newline=False) with suppress_stdout_stderr(): # subprocess.check_output("bash -c 'pyenv local 3.6.5 && pip install git+https://[email protected]/sidebarchats/dewey.git#egg=dewey --upgrade --force'", shell=True,) subprocess.check_output( "bash -c 'pyenv local 2.7.7 && pip install git+https://[email protected]/sidebarchats/dewey.git#egg=dewey --upgrade --force'", shell=True, ) puts("complete.") except subprocess.CalledProcessError as grepexc: puts("\nError upgrading dewey. \n%s" % (grepexc.output, ))
def main(): # Handle pre/post handlers run_pre = False run_post = False if "--pre" in sys.argv: run_pre = True sys.argv.remove("--pre") if "--post" in sys.argv: run_post = True sys.argv.remove("--post") # Platform detection platform = None if sys.platform == "win32": platform = "Windows" elif sys.platform == "darwin": platform = "MacOSX" elif sys.platform == "linux2": platform = "Linux" arguments = {} if run_pre or run_post: with suppress_stdout_stderr(): try: arguments = docopt(__doc__, version='Dewey %s' % VERSION) except: pass else: arguments = docopt(__doc__, version='Dewey %s' % VERSION) for arg_name, value in arguments.items(): if value is True: arg_name = arg_name.replace("-", "_") try: command_module = __import__("dewey.commands.%s" % arg_name, fromlist=['Command']) cmd = getattr(command_module, 'Command')() cmd.set_platform(platform) if run_pre: print(cmd.run_pre(**arguments)) elif run_post: print(cmd.run_post(**arguments)) else: cmd.run_command(**arguments) except: if not run_pre and not run_post: import traceback traceback.print_exc() print("Unable to find a command module for %s" % arg_name)
def main(): # Handle pre/post handlers run_pre = False run_post = False if "--pre" in sys.argv: run_pre = True sys.argv.remove("--pre") if "--post" in sys.argv: run_post = True sys.argv.remove("--post") # Platform detection platform = None if sys.platform == "win32": platform = "Windows" elif sys.platform == "darwin": platform = "MacOSX" elif sys.platform == "linux2": platform = "Linux" arguments = {} if run_pre or run_post: with suppress_stdout_stderr(): try: arguments = docopt(__doc__, version='Dewey %s' % VERSION) except: pass else: arguments = docopt(__doc__, version='Dewey %s' % VERSION) for arg_name, value in arguments.iteritems(): if value == True: arg_name = arg_name.replace("-", "_") try: command_module = __import__("dewey.commands.%s" % arg_name, fromlist=['Command']) cmd = getattr(command_module, 'Command')() cmd.set_platform(platform) if run_pre: print cmd.run_pre(**arguments) elif run_post: print cmd.run_post(**arguments) else: cmd.run_command(**arguments) except: if not run_pre and not run_post: import traceback; traceback.print_exc(); print "Unable to find a command module for %s" % arg_name