def take_action(self, action, dest, opt, value, values, parser): """extended take_action""" orig_action = action # keep copy if action == 'shorthelp': parser.print_shorthelp() parser.exit() elif action in ('store_true', 'store_false', 'store_debuglog'): if action == 'store_debuglog': action = 'store_true' if opt.startswith("--%s-" % self.ENABLE): # keep action pass elif opt.startswith("--%s-" % self.DISABLE): # reverse action if action in ('store_true', 'store_debuglog'): action = 'store_false' elif action in ('store_false', ): action = 'store_true' if orig_action == 'store_debuglog' and action == 'store_true': setLogLevelDebug() Option.take_action(self, action, dest, opt, value, values, parser) elif action in self.EXTOPTION_EXTRA_OPTIONS: if action == "extend": # comma separated list convert in list lvalue = value.split(self.EXTEND_SEPARATOR) values.ensure_value(dest, []).extend(lvalue) elif action == "date": lvalue = date_parser(value) setattr(values, dest, lvalue) elif action == "datetime": lvalue = datetime_parser(value) setattr(values, dest, lvalue) else: raise (Exception( "Unknown extended option action %s (known: %s)" % (action, self.EXTOPTION_EXTRA_OPTIONS))) else: Option.take_action(self, action, dest, opt, value, values, parser) # set flag to mark as passed by action (ie not by default) # - distinguish from setting default value through option if hasattr(values, '_action_taken'): values._action_taken[dest] = True
def take_action(self, action, dest, opt, value, values, parser): """extended take_action""" orig_action = action # keep copy if action == 'shorthelp': parser.print_shorthelp() parser.exit() elif action in ('store_true', 'store_false', 'store_debuglog'): if action == 'store_debuglog': action = 'store_true' if opt.startswith("--%s-" % self.ENABLE): # keep action pass elif opt.startswith("--%s-" % self.DISABLE): # reverse action if action in ('store_true', 'store_debuglog'): action = 'store_false' elif action in ('store_false',): action = 'store_true' if orig_action == 'store_debuglog' and action == 'store_true': setLogLevelDebug() Option.take_action(self, action, dest, opt, value, values, parser) elif action in self.EXTOPTION_EXTRA_OPTIONS: if action == "extend": # comma separated list convert in list lvalue = value.split(self.EXTEND_SEPARATOR) values.ensure_value(dest, []).extend(lvalue) elif action == "date": lvalue = date_parser(value) setattr(values, dest, lvalue) elif action == "datetime": lvalue = datetime_parser(value) setattr(values, dest, lvalue) else: raise(Exception("Unknown extended option action %s (known: %s)" % (action, self.EXTOPTION_EXTRA_OPTIONS))) else: Option.take_action(self, action, dest, opt, value, values, parser) # set flag to mark as passed by action (ie not by default) # - distinguish from setting default value through option if hasattr(values, '_action_taken'): values._action_taken[dest] = True
def make_worker_log(name, debug=False, logfn_name=None, disable_defaulthandlers=False): """Make a basic log object""" if logfn_name is None: logfn_name = name logfn = '/tmp/scoop_%s.log' % logfn_name if debug: setLogLevelDebug() logToFile(logfn, name=name) os.chmod(logfn, stat.S_IRUSR | stat.S_IWUSR) if disable_defaulthandlers: disableDefaultHandlers() _log = getLogger(name=name) return _log
help="Choose the branch to link to (default easybuild-easyconfigs).") parser.add_option("-p", "--path", action="store", dest="path", help="Specify a path inside the repo (default easybuild/easyconfigs).") parser.add_option("-l", "--local", action="store_true", dest="local", help="Use a local path, not on github.com (Default false)") options, args = parser.parse_args() # get and configure logger log = fancylogger.getLogger(__name__) if options.verbose == 1: fancylogger.setLogLevelWarning() elif options.verbose == 2: fancylogger.setLogLevelInfo() elif options.verbose >= 3: fancylogger.setLogLevelDebug() if options.quiet: fancylogger.logToScreen(False) else: fancylogger.logToScreen(True) # other options if not options.branch: options.branch = "develop" if not options.username: options.username = "******" if not options.repo: options.repo = "easybuild-easyconfigs" if not options.path: options.path = "easybuild/easyconfigs"
parser.add_option("-l", "--local", action="store_true", dest="local", help="Use a local path, not on github.com (Default false)") options, args = parser.parse_args() # get and configure logger log = fancylogger.getLogger(__name__) if options.verbose == 1: fancylogger.setLogLevelWarning() elif options.verbose == 2: fancylogger.setLogLevelInfo() elif options.verbose >= 3: fancylogger.setLogLevelDebug() if options.quiet: fancylogger.logToScreen(False) else: fancylogger.logToScreen(True) # other options if not options.branch: options.branch = "develop" if not options.username: options.username = "******" if not options.repo: options.repo = "easybuild-easyconfigs" if not options.path: options.path = "easybuild/easyconfigs" if options.local:
if prio < PRIO_MIN or prio > PRIO_MAX: _logger.raiseException("setpriority: prio not in allowed range MIN %s MAX %s" % (PRIO_MIN, PRIO_MAX)) ec = _libc.setpriority(priority_which_t(which), id_t(who), ctypes.c_int(prio) ) if ec == 0: _logger.debug("setpriority for which %s who %s prio %s" % (which, who, prio)) else: _logger.error("setpriority failed for which %s who %s prio %s" % (which, who, prio)) if __name__ == '__main__': ## some examples of usage setLogLevelDebug() cs = cpu_set_t() print "__bits", cs.__bits print "sizeof cpu_set_t", ctypes.sizeof(cs) x = sched_getaffinity() print "x", x hr_mask = "1-5,7,9,10-15" print hr_mask, x.convert_hr_bits(hr_mask) print x x.set_bits() print x sched_setaffinity(x) print sched_getaffinity()
"setpriority: prio not in allowed range MIN %s MAX %s" % (PRIO_MIN, PRIO_MAX)) ec = _libc.setpriority(priority_which_t(which), id_t(who), ctypes.c_int(prio)) if ec == 0: _logger.debug("setpriority for which %s who %s prio %s" % (which, who, prio)) else: _logger.error("setpriority failed for which %s who %s prio %s" % (which, who, prio)) if __name__ == '__main__': ## some examples of usage setLogLevelDebug() cs = cpu_set_t() print "__bits", cs.__bits print "sizeof cpu_set_t", ctypes.sizeof(cs) x = sched_getaffinity() print "x", x hr_mask = "1-5,7,9,10-15" print hr_mask, x.convert_hr_bits(hr_mask) print x x.set_bits() print x sched_setaffinity(x) print sched_getaffinity()
def set_debug(self): """Check if debug options are on and then set fancylogger to debug""" if self.options is None: if self.DEBUG_OPTIONS_BUILD: setLogLevelDebug()