def help(return_code=0): '''print help, including the software version and active client and exit with return code. ''' version = watchme.__version__ bot.custom(message='Command Line Tool v%s' % version, prefix='\n[WatchMe] ', color='CYAN') parser.print_help() sys.exit(return_code)
def help(return_code=0): """print help, including the software version and active client and exit with return code. """ version = watchme.__version__ bot.custom( message="Command Line Tool v%s" % version, prefix="\n[WatchMe] ", color="CYAN", ) parser.print_help() sys.exit(return_code)
def print_section(self, section): '''print a section (usually a task) from a configuration file, if it exists. Parameters ========== section: the name of the section (task) ''' self.load_config() if section in self.config: bot.info('[%s]' % section) for key in self.config[section]: value = self.config[section][key] bot.custom(prefix=key, message=" = %s" % value, color="CYAN") else: bot.exit('%s is not a valid section.' % section)
def list_watcher(watcher, base=None): '''list the contents (tasks) of a single watcher. Parameters ========== base: the watchme base, defaults to $HOME/.watchme ''' if base == None: base = WATCHME_BASE_DIR repo = os.path.join(base, watcher) if os.path.exists(repo): files = os.listdir(repo) bot.custom(prefix="task:", message="%s" % repo, color="CYAN") bot.info('\n '.join(files)) else: bot.exit('%s does not exist.' % base)
def _general_list(path, prefix="path", base=None): """a shared function for listing (and returning) files. Parameters ========== path: the full path to list, if it exists prefix: a prefix to print for the type base: the watchme base, defaults to $HOME/.watchme """ if base is None: base = WATCHME_BASE_DIR if os.path.exists(path): files = os.listdir(path) bot.custom(prefix="%s:" % prefix, message="%s" % path, color="CYAN") bot.info("\n ".join(files)) else: bot.exit("%s does not exist." % base)
def list_watcher_types(): """list the exporter options provided by watchme""" bot.custom(prefix="watchme:", message="watcher task types", color="CYAN") bot.info("\n ".join(WATCHME_TASK_TYPES))