def _createCommitNewFile(self, filename, subject=None, message=None): phlsys_subprocess.run_commands( "touch " + os.path.join(self.path, filename)) self.repo("add", filename) if not subject: if message: raise Exception("didn't expect message with empty subject") self.repo( "commit", "-a", "-m", filename, "--author", self.author) elif not message: self.repo( "commit", "-a", "-m", subject, "--author", self.author) else: message = subject + "\n\n" + message self.repo( "commit", "-a", "-m", message, "--author", self.author)
def _createCommitNewFile(self, filename): phlsys_subprocess.run_commands( "touch " + os.path.join(self.path, filename)) self.clone.call("add", filename) self.clone.call("commit", "-a", "-m", filename)
def tearDown(self): phlsys_subprocess.run_commands("rm -rf " + self.path)
def setUp(self): # TODO: make this more portable with shutil etc. phlsys_subprocess.run_commands("mkdir " + self.path) phlsys_subprocess.run("git", "init", workingDir=self.path) self.clone = phlsys_git.GitClone(self.path)
def test_run_multi_commands(self): "Run multiple cmds - returns None" self.assertEqual(None, phlsys_subprocess.run_commands( "echo hello stdout", "echo goodbye stdout"))
def test_run_commands(self): "Run simple cmds - returns None" self.assertEqual( None, phlsys_subprocess.run_commands("echo hello stdout"))
def setUp(self): # TODO: make this more portable with shutil etc. phlsys_subprocess.run_commands("mkdir " + self.path) phlsys_subprocess.run("git", "init", workingDir=self.path) self.repo = phlsys_git.Repo(self.path)
def runCommands(*commands): phlsys_subprocess.run_commands(*commands)
def run_once(args, out): sender = phlmail_sender.MailSender( phlsys_sendmail.Sendmail(), args.arcyd_email) mailer = abdmail_mailer.Mailer( sender, [args.admin_email], args.repo_desc, args.instance_uri) # TODO: this should be a URI for users not conduit # prepare delays in the event of trouble when fetching or connecting # TODO: perhaps this policy should be decided higher-up delays = [ datetime.timedelta(seconds=1), datetime.timedelta(seconds=1), datetime.timedelta(seconds=10), datetime.timedelta(seconds=10), datetime.timedelta(seconds=100), datetime.timedelta(seconds=100), datetime.timedelta(seconds=1000), ] # log.error if we get an exception when fetching def on_exception(e, delay): logging.error(str(e) + "\nwill wait " + str(delay)) if args.try_touch_path: try: # TODO: don't rely on the touch command phlsys_subprocess.run("touch", args.try_touch_path) except Exception: pass # XXX: we don't care atm, later log this with phlsys_fs.chdir_context(args.repo_path): out.display("fetch (" + args.repo_desc + "): ") phlsys_tryloop.try_loop_delay( lambda: phlsys_subprocess.run_commands("git fetch -p"), delays, onException=on_exception) # XXX: until conduit refreshes the connection, we'll suffer from # timeouts; reduce the probability of this by using a new # conduit each time. # create an array so that the 'connect' closure binds to the 'conduit' # variable as we'd expect, otherwise it'll just modify a local variable # and this 'conduit' will remain 'None' # XXX: we can do better in python 3.x conduit = [None] def connect(): #nonlocal conduit # XXX: we'll rebind in python 3.x, instead of array conduit[0] = phlsys_conduit.Conduit( args.instance_uri, args.arcyd_user, args.arcyd_cert, https_proxy=args.https_proxy) phlsys_tryloop.try_loop_delay(connect, delays, onException=on_exception) out.display("process (" + args.repo_desc + "): ") abdi_processrepo.processUpdatedRepo( conduit[0], args.repo_path, "origin", mailer) if args.ok_touch_path: try: # TODO: don't rely on the touch command phlsys_subprocess.run("touch", args.ok_touch_path) except Exception: pass # XXX: we don't care atm, later log this
def prune_and_fetch(): phlsys_subprocess.run_commands("git remote prune origin") phlsys_subprocess.run_commands("git fetch")
def test_run_multi_commands(self): "Run multiple cmds - returns None" self.assertEqual( None, phlsys_subprocess.run_commands("echo hello stdout", "echo goodbye stdout"))
def test_run_commands(self): "Run simple cmds - returns None" self.assertEqual(None, phlsys_subprocess.run_commands("echo hello stdout"))