def __init__(self, name="memory_logger"): """ Constructor. """ Logger.__init__(self, name) self.megabyte = float(2**20) self.memory = {} self.memory['Completion'] = 0 return
def __init__(self, name="memory_logger"): """ Constructor. """ Logger.__init__(self, name) self.megabyte = float(2**20) self.memory = {} self.memory['Completion'] = 0 return
def __init__(self, category, label=None, manual_reprime=0, nofail=1, immediate=1): """If specified, optional label is included after timestamp. Other options are passed to the Logger class initializer. """ self.__label = label self.__manual_reprime = manual_reprime self.__primed = 1 self.__bol = 1 Logger.__init__(self, category, nofail, immediate)
def __init__(self, xml_node=None): Logger.__init__(self) self._str_dut_id = None self._str_name = None #self._dict_ports = {} self._str_type = None self._reset_status() self._xmlnode_dut = None self.ports = list() self._lock_status = Lock() self._b_port_ready = False self._str_configuration = '' if xml_node is not None: self.from_xml_node(xml_node)
def __init__(self, controller_type, brick_layout_type): Logger.__init__(self) self._running = True self._display_surf = None self._image_surf = None self._food_surf = None self._brick_image = None self.game = Game() self.snake = Snake(3, self.windowHeight, self.windowWidth) self.bricks = Bricks(5, 5, brick_layout_type) self.food = Food() self.food.generate_food(self.snake, self.bricks) self._score = 0 # this needs to be updated as required self.controller_type = controller_type self.snake_controller = constants.controller_name_mapping[ controller_type]()
def __init__(self, **kwargs): kwargs['plugin_info_ext'] = 'dpx-plugin' PluginManager.__init__(self, **kwargs) Logger.__init__(self) #Compromise self.setPluginPlaces(['plugins']) self.setCategoriesFilter({ 'Parse': BasePlugin.ParserPlugin, 'Draw': BasePlugin.DrawPlugin }) self.debug('Collecting / firing plugins') self.collectPlugins() plugins = self.getAllPlugins() names = [x.name for x in plugins] categories = self.getCategories() if len(plugins) > 0: self.debug('Collected plugins: {0}'.format(names)) else: self.error('No plugins were collected!', 'ouch') for p in plugins: self.activatePluginByName(p.name, p.category)
def __init__(self, **kw): Logger.__init__(self,**kw)
def __init__(self, name, usage=None, rc=Struct(opts=None, args=None), user_ns=None): # Put a reference to self in builtins so that any form of embedded or # imported code can test for being inside IPython. __builtin__.__dict__['__IPYTHON__'] = self # Keep in the builtins a flag for when IPython is active. We set it # with setdefault so that multiple nested IPythons don't clobber one # another. Each will increase its value by one upon being activated, # which also gives us a way to determine the nesting level. __builtin__.__dict__.setdefault('__IPYTHON__active', 0) # Create the namespace where the user will operate: # FIXME. For some strange reason, __builtins__ is showing up at user # level as a dict instead of a module. This is a manual fix, but I # should really track down where the problem is coming from. Alex # Schmolck reported this problem first. if user_ns is None: self.user_ns = { '__name__': '__IPYTHON__main__', name: self, '__builtins__': __builtin__, } else: self.user_ns = user_ns # We need to insert into sys.modules something that looks like a # module but which accesses the IPython namespace, for shelve and # pickle to work interatctively. Normally they rely on getting # everything out of __main__, but for embedding purposes each IPython # instance has its own private namespace, so we can't go shoving # everything into __main__. try: main_name = self.user_ns['__name__'] except KeyError: raise KeyError, 'user_ns dictionary MUST have a "__name__" key' else: sys.modules[main_name] = _FakeModule(self.user_ns) # List of input with multi-line handling. # Fill its zero entry, user counter starts at 1 self.input_hist = InputList(['\n']) # list of visited directories self.dir_hist = [os.getcwd()] # dict of output history self.output_hist = {} # make global variables for user access to these self.user_ns['_ih'] = self.input_hist self.user_ns['_oh'] = self.output_hist self.user_ns['_dh'] = self.dir_hist # user aliases to input and output histories self.user_ns['In'] = self.user_ns['_ih'] self.user_ns['Out'] = self.user_ns['_oh'] # class initializations code.InteractiveConsole.__init__(self, locals=self.user_ns) Logger.__init__(self, log_ns=self.user_ns) Magic.__init__(self) # an ugly hack to get a pointer to the shell, so I can start writing magic # code via this pointer instead of the current mixin salad. Magic.set_shell(self, self) # hooks is a Struct holding pointers to various system hooks, and will # be used for further user-side customizations in the future #self.hooks = Struct(ps1 = sys.ps1,ps2 = sys.ps2,display = sys.displayhook) self.hooks = Struct() self.name = name self.usage_min = """\ An enhanced console for Python. Features are: - Readline support if present - Completion in the local namespace, eg. type TAB twice at the prompt. - Logging of input, see command-line options. - Systemshell escape by the ! , eg !ls - Magic commands, starting with a @ (like @ls, @pwd, @cd, etc.) - Keeps track of locally defined variables @who, @whos - Show object information with a ? eg ?x or x? (use ?? for more info). """ if usage: self.usage = usage else: self.usage = self.usage_min # Storage self.rc = rc # This will hold all configuration information self.inputcache = [] self._boundcache = [] self.pager = 'less' # temporary files used for various purposes. Deleted at exit. self.tempfiles = [] # for pushd/popd management try: self.home_dir = get_home_dir() except HomeDirError: if os.name == 'dos': # final, desperate hack for Win9x self.home_dir = os.path.join('C:', 'Program Files', 'IPython') else: print 'Unsupported operating system:', os.name print 'Exiting...' sys.exit() self.dir_stack = [os.getcwd().replace(self.home_dir, '~')] # escapes for automatic behavior on the command line self.ESC_SHELL = '!' self.ESC_HELP = '?' self.ESC_MAGIC = '@' self.ESC_QUOTE = ',' self.ESC_PAREN = '/' # RegExp for splitting line contents into pre-char//first word-method//rest # update the regexp if the above escapes are changed self.line_split = re.compile( r'(^[\s*!\?@,/]?)([\?\w\.]+\w*\s*)(\(?.*$)') # RegExp to identify potential function names self.fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) ?$') # try to catch also methods for stuff in lists/tuples/dicts: # off (experimental). For this to work, the line_split regexp would # need to be modified so it wouldn't break things at '['. That line # is nasty enough that I shouldn't change it until I can test it _well_. #self.fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') # keep track of where we started running (mainly for crash post-mortem) self.starting_dir = os.getcwd() # Attributes for Logger mixin class, make defaults here self._dolog = 0 self.LOG = '' self.LOGDEF = '.InteractiveShell.log' self.LOGMODE = 'over' self.LOGHEAD = Itpl( """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW #log# opts = $self.rc.opts #log# args = $self.rc.args #log# It is safe to make manual edits below here. #log#----------------------------------------------------------------------- """) # Various switches which can be set self.CACHELENGTH = 5000 # this is cheap, it's just text self.BANNER = itpl("Python $sys.version on $sys.platform\n" "$sys.copyright\nIPP\nType ? for more help\n") # TraceBack handlers: # Need two, one for syntax errors and one for other exceptions. # plain/color self.SyntaxTB = ultraTB.ListTB(color_scheme='NoColor') # This one is initialized with an offset, meaning we always want to # remove the topmost item in the traceback, which is our own internal # code. Valid modes: plain/color/verbose self.InteractiveTB = ultraTB.AutoFormattedTB(mode='Plain', color_scheme='NoColor', tb_offset=1) # Object inspector ins_colors = OInspect.InspectColors code_colors = PyColorize.ANSICodeColors self.inspector = OInspect.Inspector(ins_colors, code_colors, 'NoColor') # List of shell commands to auto-define if os.name == 'posix': auto_shell = { 'ls': 'ls -F', 'mkdir': 'mkdir', 'rmdir': 'rmdir', 'mv': 'mv', 'rm': 'rm -i', 'rmf': 'rm -f', 'less': 'less', 'cat': 'cat', 'clear': 'clear', 'lc': 'ls -F -o --color' } elif os.name == 'nt': auto_shell = { 'dir': 'dir /on', 'ls': 'dir /on', 'ddir': 'dir /ad /on', 'ld': 'dir /ad /on', 'mkdir': 'mkdir', 'rmdir': 'rmdir', 'ren': 'ren', 'cls': 'cls', 'more': 'type', 'type': 'type' } else: auto_shell = {} for name, cmd in auto_shell.items(): self.magic_alias(name + ' ' + cmd)