def __init__(self, ui, token=None): self.ui = ui self.token = token self.debugrequests = ui.config("commitcloud", "debugrequests") self.remote_host = ui.config("commitcloud", "remote_host") self.remote_port = ui.configint("commitcloud", "remote_port") self.client_certs = util.expanduserpath( ui.config("commitcloud", "tls.client_certs")) self.ca_certs = util.expanduserpath( ui.config("commitcloud", "tls.ca_certs")) self.check_hostname = ui.configbool("commitcloud", "tls.check_hostname") # validation if not self.remote_host: raise ccerror.ConfigurationError(self.ui, _("'remote_host' is required")) if self.client_certs and not os.path.isfile(self.client_certs): raise ccerror.TLSConfigurationError( ui, _("%s (no such file or is a directory)") % self.client_certs) if self.ca_certs and not os.path.isfile(self.ca_certs): raise ccerror.TLSConfigurationError( ui, _("%s (no such file or is a directory)") % self.ca_certs) self._setuphttpsconnection()
def scmdaemonlog(ui, repo): logpath = ui.config("commitcloud", "scm_daemon_log_path") if not logpath: return "'commitcloud.scm_daemon_log_path' is not set in the config" logpath = util.expanduserpath(logpath) if not os.path.exists(logpath): return "%s: no such file or directory" % logpath # grab similar files as the original path to include rotated logs as well logfiles = [ f for f in os.listdir(os.path.dirname(logpath)) if os.path.basename(logpath) in f ] return _tail(os.path.dirname(logpath), logfiles, 150)
def cloudstatus(ui, repo, **opts): """Shows information about the state of the user's workspace""" workspacename = workspace.currentworkspace(repo) if workspacename is None: ui.write(_("You are not connected to any workspace\n")) return ui.write(_("Workspace: %s\n") % workspacename) backgroundnabled = background.autobackupenabled(repo) autosync = "ON" if backgroundnabled else "OFF" ui.write(_("Automatic Sync (on local changes): %s\n") % autosync) if backgroundnabled and subscription.testservicestatus(repo): ui.write( _("Automatic Sync via 'Scm Daemon' (on remote changes): ON\n")) logpath = util.expanduserpath( ui.config("commitcloud", "scm_daemon_log_path", "")) if logpath: ui.write(_("Scm Daemon Log Path: %s\n") % logpath) else: ui.write( _("Automatic Sync via 'Scm Daemon' (on remote changes): OFF\n")) state = syncstate.SyncState(repo, workspacename) ui.write(_("Last Sync Version: %s\n") % state.version) if state.maxage is not None: ui.write(_("Last Sync Maximum Commit Age: %s days\n") % state.maxage) ui.write( _("Last Sync Heads: %d (%d omitted)\n") % (len(state.heads), len(state.omittedheads))) ui.write( _("Last Sync Bookmarks: %d (%d omitted)\n") % (len(state.bookmarks), len(state.omittedbookmarks))) ui.write( _("Last Sync Remote Bookmarks: %d\n") % (len(state.remotebookmarks))) ui.write(_("Last Sync Snapshots: %d\n") % (len(state.snapshots))) ui.write(_("Last Sync Time: %s\n") % time.ctime(state.lastupdatetime)) if repo.svfs.isfile(sync._syncstatusfile): status = pycompat.decodeutf8(repo.svfs.read(sync._syncstatusfile)) else: status = "Not logged" ui.write(_("Last Sync Status: %s\n") % status)