def filters_command( alias="", # If a filter alias is specified, more detailed help for that filter is printed. nocolor=False, # When source = True, whether to omit syntax highlighting showall=False, # Whether to show all filters, including those which need missing software, implies versions=True showmissing=False, # Whether to just show filters missing external software, implies versions=True space=False, # Whether to add extra spacing to the output for extra readability source=False, # Whether to include syntax-highlighted source code when displaying an indvidual filter versions=False # Whether to check the installed version of external software required by filters, slower ): """ Lists the available dexy filters and their aliases. Does not include filters which require python modules that are not installed. Consult the Dexy website http://dexy.it for a complete list of filters. """ if len(alias) == 0: # This tends to be slow, let people know it's running print "looking up filter information..." else: if showall: raise Exception("can't specify an alias if showall is True") if check_setup(): log = get_log() else: log = Constants.NULL_LOGGER print filters_text(alias, nocolor, showall, showmissing, space, source, versions, log)
def fcmd_command( alias=None, # The alias of the filter which defines the custom command cmd=None, # The name of the command to run help=False, # If true, just print docstring rather than running command **kwargs # Additional arguments to be passed to the command ): """ Run a command defined in a dexy filter. """ if check_setup(): log = get_log() else: log = Constants.NULL_LOGGER filters_dict = dexy.introspect.filters(log) filter_class = filters_dict[alias] cmd_name = "docmd_%s" % cmd if not filter_class.__dict__.has_key(cmd_name): raise Exception("%s is not a valid command. There is no method %s defined in %s" % (cmd, cmd_name, filter_class.__name__)) else: class_method = filter_class.__dict__[cmd_name] if type(class_method) == classmethod: if help: print class_method.__func__.__doc__ else: class_method.__func__(filter_class, **kwargs) else: raise Exception("expected %s to be a classmethod of %s" % (cmd_name, filter_class.__name__))
def __init__(self, args={}): self.args = args # arguments from command line self.config = {} # config to be processed from .dexy files self.docs = [] self.timing = [] self.virtual_docs = [] self.batch_start_time = None self.batch_finish_time = None self.batch_elapsed_time = None # Set up logging if args.has_key("logsdir") and args.has_key("logfile"): self.log = get_log("dexy.controller", args['logsdir'], args['logfile'], args['loglevel']) else: self.log = Constants.NULL_LOGGER # Set up db if args.has_key('dbclass') and args.has_key("logsdir") and args.has_key("dbfile"): self.db = dexy.utils.get_db(self.args['dbclass'], logsdir=self.args['logsdir'], dbfile=args['dbfile']) else: self.db = None # List of directories that reporters use, these will not be processed by dexy self.reports_dirs = dexy.introspect.reports_dirs(self.log) # list of artifact classes - if nothing else uses this then move # it into the if statement below and don't cache it self.artifact_classes = dexy.introspect.artifact_classes(self.log) if args.has_key('artifactclass'): if self.artifact_classes.has_key(args['artifactclass']): self.artifact_class = self.artifact_classes[args['artifactclass']] else: raise Exception("Artifact class name %s not found in %s" % (args['artifactclass'], ",".join(self.artifact_classes.keys())))
def __init__(self, args={}): self.args = args # arguments from command line self.config = {} # config to be processed from .dexy files self.docs = [] # Set up logging if args.has_key("logsdir") and args.has_key("logfile"): self.log = get_log("dexy.controller", args['logsdir'], args['logfile']) else: self.log = Constants.NULL_LOGGER # Set up db if args.has_key('dbclass') and args.has_key("logsdir") and args.has_key("dbfile"): self.db = dexy.utils.get_db(self.args['dbclass'], logsdir=self.args['logsdir'], dbfile=args['dbfile']) else: self.db = {} # List of directories that reporters use, these will not be processed by dexy self.reports_dirs = dexy.introspect.reports_dirs(self.log) # list of artifact classes - if nothing else uses this then move # it into the if statement below and don't cache it self.artifact_classes = dexy.introspect.artifact_classes(self.log) if args.has_key('artifactclass'): self.artifact_class = self.artifact_classes[args['artifactclass']]
def fcmds_command(alias=None): """ Returns a list of available filter commands (fcmds) defined by the specified alias. These commands can then be run using the fcmd command. """ if check_setup(): log = get_log() else: log = Constants.NULL_LOGGER filters_dict = dexy.introspect.filters(log) filter_class = filters_dict[alias] print "Filter commands defined in %s..." % filter_class.__name__ cmds = [] for m in dir(filter_class): if m.startswith("docmd_"): cmds.append(m.replace("docmd_", "")) print "\n".join(sorted(cmds))
def setup(): log = get_log() remove_all_handlers(log)
def setup(): log = get_log(logsdir=None, logfile=None) remove_all_handlers(log)