def get_conduit_and_cache_for_args(self, args): key = (args.instance_uri, args.arcyd_user, args.arcyd_cert, args.https_proxy) if key not in self._conduits_caches: # 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 _process_repo better in python 3.x (nonlocal?) conduit = [None] def connect(): # XXX: we'll rebind in python 3.x, instead # nonlocal conduit conduit[0] = phlsys_conduit.MultiConduit( args.instance_uri, args.arcyd_user, args.arcyd_cert, https_proxy=args.https_proxy) abdt_tryloop.tryloop(connect, abdt_errident.CONDUIT_CONNECT, args.instance_uri) multi_conduit = conduit[0] cache = phlcon_reviewstatecache.make_from_conduit(multi_conduit) arcyd_conduit = abdt_conduit.Conduit(multi_conduit, cache) self._conduits_caches[key] = (arcyd_conduit, cache) else: arcyd_conduit, cache = self._conduits_caches[key] return arcyd_conduit, cache
def get_conduit_and_cache_for_args(self, args): key = ( args.instance_uri, args.arcyd_user, args.arcyd_cert, args.https_proxy ) if key not in self._conduits_caches: # 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 _process_repo better in python 3.x (nonlocal?) conduit = [None] def connect(): # XXX: we'll rebind in python 3.x, instead # nonlocal conduit conduit[0] = phlsys_conduit.MultiConduit( args.instance_uri, args.arcyd_user, args.arcyd_cert, https_proxy=args.https_proxy) abdt_tryloop.tryloop( connect, abdt_errident.CONDUIT_CONNECT, args.instance_uri) multi_conduit = conduit[0] cache = phlcon_reviewstatecache.make_from_conduit(multi_conduit) arcyd_conduit = abdt_conduit.Conduit(multi_conduit, cache) self._conduits_caches[key] = (arcyd_conduit, cache) else: arcyd_conduit, cache = self._conduits_caches[key] return arcyd_conduit, cache
def _connect(conduits, args, arcyd_reporter): key = ( args.instance_uri, args.arcyd_user, args.arcyd_cert, args.https_proxy) if key not in conduits: # 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 (nonlocal?) conduit = [None] def connect(): # nonlocal conduit # XXX: we'll rebind in python 3.x, instead conduit[0] = phlsys_conduit.Conduit( args.instance_uri, args.arcyd_user, args.arcyd_cert, https_proxy=args.https_proxy) with arcyd_reporter.tag_timer_context('conduit connect'): abdt_tryloop.tryloop( connect, abdt_errident.CONDUIT_CONNECT, args.instance_uri) conduit = conduit[0] arcyd_reporter.tag_timer_decorate_object_methods_individually( conduit, 'base_conduit') arcyd_conduit = abdt_conduit.Conduit(conduit) arcyd_reporter.tag_timer_decorate_object_methods_individually( arcyd_conduit, 'conduit') conduits[key] = arcyd_conduit else: arcyd_conduit = conduits[key] return arcyd_conduit
def _fetch_if_needed(url_watcher, snoop_url, repo, repo_desc): did_fetch = False # fetch only if we need to if not snoop_url or url_watcher.has_url_recently_changed(snoop_url): abdt_tryloop.tryloop( repo.fetch_prune, abdt_errident.FETCH_PRUNE, repo_desc) did_fetch = True return did_fetch
def fetch_if_needed(url_watcher, snoop_url, repo, repo_desc): did_fetch = False # fetch only if we need to if not snoop_url or url_watcher.peek_has_url_recently_changed(snoop_url): abdt_tryloop.tryloop(repo.checkout_master_fetch_prune, abdt_errident.FETCH_PRUNE, repo_desc) did_fetch = True if did_fetch and snoop_url: # consume the 'newness' of this repo, since fetching succeeded url_watcher.has_url_recently_changed(snoop_url) return did_fetch
def _fetch_if_needed(url_watcher, snoop_url, repo, repo_desc): did_fetch = False # fetch only if we need to if not snoop_url or url_watcher.peek_has_url_recently_changed(snoop_url): abdt_tryloop.tryloop( repo.fetch_prune, abdt_errident.FETCH_PRUNE, repo_desc) did_fetch = True if did_fetch and snoop_url: # consume the 'newness' of this repo, since fetching succeeded url_watcher.has_url_recently_changed(snoop_url) return did_fetch
def _fetch_if_needed(url_watcher, args, out, arcyd_reporter, repo_desc): did_fetch = False def prune_and_fetch(): phlsys_subprocess.run_commands("git remote prune origin") phlsys_subprocess.run_commands("git fetch") # fetch only if we need to snoop_url = args.repo_snoop_url if not snoop_url or url_watcher.has_url_recently_changed(snoop_url): with phlsys_fs.chdir_context(args.repo_path): out.display("fetch (" + repo_desc + "): ") with arcyd_reporter.tag_timer_context('git fetch'): abdt_tryloop.tryloop( prune_and_fetch, 'fetch/prune', repo_desc) did_fetch = True return did_fetch
def _tryloop(self, f, identifier): return abdt_tryloop.tryloop(f, identifier, self.describe())