コード例 #1
0
    def __init__(self, group_name=None, default_target=None, default_args=None, default_kwargs=None,
                 default_flags=None, default_kill_wait=0.5, max_processes=1000, process_plus_impl=None):

        self.group_name = group_name

        self._defaults = dict(
            target=default_target,
            args=default_args,
            kwargs=default_kwargs,
            flags=self._curate_flags(default_flags),
            kill_wait=default_kill_wait
        )

        self.max_processes = max_processes

        if process_plus_impl:
            assert issubclass(process_plus_impl, ProcessPlus)

        self.ProcessPlusImpl = ProcessPlus if not process_plus_impl else process_plus_impl

        self.__limbo_group = None  # Must access through property
        self.__dead_group = None  # Must access through property

        self._num_keep_dead = 100
        self._num_deleted_dead = 0

        self.logger = logging.getLogger(__name__)

        self._thread_action_loop = None
        self.stop_action = True
        self.action_loop_interval = 1  # seconds between each actions pass

        IterableUserDict.__init__(self)
コード例 #2
0
    def __init__(self, initialdata=None, tag=None, **kwargs):
        """Constructor

        Parameters
        -----------
        initialdata : dict or dataId
            A dict of initial data for the DataId
        tag : any type, or a container of any type
            A value or container of values used to restrict the DataId to one or more repositories that
            share that tag value. It will be stored in a set for comparison with the set of tags assigned to
            repositories.
        kwargs : any values
            key-value pairs to be used as part of the DataId's data.
        """
        UserDict.__init__(self, initialdata)
        try:
            self.tag = copy.deepcopy(initialdata.tag)
        except AttributeError:
            self.tag = set()

        if tag is not None:
            if isinstance(tag, basestring):
                self.tag.update([tag])
            else:
                try:
                    self.tag.update(tag)
                except TypeError:
                    self.tag.update([tag])

        self.data.update(kwargs)
コード例 #3
0
    def __init__(self, d=None, path=None):
        if not path:
            path = os.path.join(os.getcwd(), 'project.pbxproj')

        self.pbxproj_path =os.path.abspath(path)
        self.source_root = os.path.abspath(os.path.join(os.path.split(path)[0], '..'))

        IterableUserDict.__init__(self, d)

        self.data = PBXDict(self.data)
        self.objects = self.get('objects')
        self.modified = False

        root_id = self.get('rootObject')
        if root_id:
            self.root_object = self.objects[root_id]
            root_group_id = self.root_object.get('mainGroup')
            self.root_group = self.objects[root_group_id]
        else:
            print "error: project has no root object"
            self.root_object = None
            self.root_group = None

        for k,v in self.objects.iteritems():
            v.id = k
コード例 #4
0
	def __init__(self, d=None, path=None):
		if not path:
			path = os.path.join(os.getcwd(), 'project.pbxproj')

		self.pbxproj_path =os.path.abspath(path)
		self.source_root = os.path.abspath(os.path.join(os.path.split(path)[0], '..'))

		IterableUserDict.__init__(self, d)

		self.data = PBXDict(self.data)
		self.objects = self.get('objects')
		self.modified = False

		root_id = self.get('rootObject')
		if root_id:
			self.root_object = self.objects[root_id]
			root_group_id = self.root_object.get('mainGroup')
			self.root_group = self.objects[root_group_id]
		else:
			print "error: project has no root object"
			self.root_object = None
			self.root_group = None

		for k,v in self.objects.iteritems():
			v.id = k
コード例 #5
0
ファイル: snmp.py プロジェクト: UnderXirox/zplugin
    def __init__(self, probe, columns):
        logger.debug('=== BEGIN NEW SNMP TABLE===')

        # This is the SNMP probe that handle SNMP communication
        self.__probe = probe

        # Get indexes and oid values
        indexes = self.__probe.getnext({'indexes':
                                        columns.pop('indexes')})['indexes']

        # Append index to all OIDs
        values = dict.fromkeys(columns, list())
        for _, index in indexes:
            cols = {}
            for name, oid in columns.viewitems():
                o = '%s.%s' % (oid, index)
                cols[name] = o
            # Query values
            results = self.__probe.get(cols)
            for k, v in results.viewitems():
                values[k].append(v)
                print values

        IterableUserDict.__init__(self, values)

        logger.debug('=== BEGIN NEW SNMP TABLE===')
コード例 #6
0
ファイル: snmp.py プロジェクト: bigbrozer/monitoring.nagios
    def __init__(self, probe, columns):
        logger.debug('=== BEGIN NEW SNMP TABLE===')

        # This is the SNMP probe that handle SNMP communication
        self.__probe = probe

        # Get indexes and oid values
        indexes = self.__probe.getnext(
            {'indexes': columns.pop('indexes')})['indexes']

        # Append index to all OIDs
        values = dict.fromkeys(columns, list())
        for _, index in indexes:
            cols = {}
            for name, oid in columns.viewitems():
                o = '%s.%s' % (oid, index)
                cols[name] = o
            # Query values
            results = self.__probe.get(cols)
            for k, v in results.viewitems():
                values[k].append(v)
                print values

        IterableUserDict.__init__(self, values)

        logger.debug('=== BEGIN NEW SNMP TABLE===')
コード例 #7
0
ファイル: settings.py プロジェクト: bjdag1234/screenly-ose
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            logging.error('Config-file %s missing', self.conf_file)
            exit(1)
        else:
            self.load()
コード例 #8
0
ファイル: settings.py プロジェクト: Geo-Joy/screenly-ose
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            logging.error('Config-file %s missing', self.conf_file)
            exit(1)
        else:
            self.load()
コード例 #9
0
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            logging.error('Config-file %s missing. Using defaults.', self.conf_file)
            self.use_defaults()
            self.save()
        else:
            self.load()
コード例 #10
0
ファイル: Config.py プロジェクト: govtmirror/DmD
 def __init__(self, useEnv=True, verboseConfig=False):
     IterableUserDict.__init__(self)
     self.verboseConfig = verboseConfig
     self.sourceAndVerboseStatus = {}
     thisDir = os.path.dirname(__file__)
     configFile = os.path.join(thisDir, "MAT_settings.config")
     if os.path.exists(configFile):
         self._readConfigFile(configFile)
     else:
         raise ConfigError, "config file doesn't exist"
     self.useEnv = useEnv
コード例 #11
0
ファイル: Histogram.py プロジェクト: TPNguyen/ucleed
 def __init__(self, cutoffs, data=None):
     """Create a HistogramBucketDict with cutoff points for buckets."""
     IterableUserDict.__init__(self)
     cutoffs = cutoffs[:]
     cutoffs.reverse()
     self.cutoffs = cutoffs
     self.firstcutoff = cutoffs[0]
     self.lastcutoff = cutoffs[-1]
     for cutoff in cutoffs:
         self[cutoff] = 0
     if data:
         self.add_all(data)
コード例 #12
0
ファイル: Histogram.py プロジェクト: drewp/waterworks
 def __init__(self, cutoffs, data=None):
     """Create a HistogramBucketDict with cutoff points for buckets."""
     IterableUserDict.__init__(self)
     cutoffs = cutoffs[:]
     cutoffs.reverse()
     self.cutoffs = cutoffs
     self.firstcutoff = cutoffs[0]
     self.lastcutoff = cutoffs[-1]
     for cutoff in cutoffs:
         self[cutoff] = 0
     if data:
         self.add_all(data)
コード例 #13
0
ファイル: sa.py プロジェクト: mrowl/filmdata
 def __init__(self, schemas, meta, name=None, seed_cols=None):
     """
     Create a new DynamicModels instance.
     Arguments:
         schemas - a list of all the schemas for the underlying tables
         meta - the meta object for this sqla session
         name - the name for this instance (will be the prefix to the
             table names)
         seed_cols - a lambda function which will generate columns present
             in each of the underlying tables
     """
     IterableUserDict.__init__(self)
     self._build(schemas, meta, name, seed_cols)
コード例 #14
0
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            try:
                with open(self.conf_file, 'w') as file:
                    pass
            except:
                logging.error('Config-file %s missing and failed to create',
                              self.conf_file)
                exit(1)
        self.load()
        self.save()
コード例 #15
0
    def __init__(self, *args, **kwargs):
        rv = IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            logging.debug('Config-file %s missing. Trying to download', self.conf_file)
            
            rsaPub = open(self.home+'/.ssh/id_rsa.pub','r')
            publicId = rsaPub.readline(512)
            rsaPub.close()
            values = {'publicId' : publicId}
            data = urllib.urlencode(values)
            req = urllib2.Request(GETCONFIG_URL, data)
            response = urllib2.urlopen(req)
            html = response.read()
            pos = html.find('\r\n\r\n')
            config = html[pos+4:]
            
            confFile = open(self.conf_file,'w')
            confFile.write(config)
            confFile.close()
            
            self.load()
        else:
            self.load()
        return rv
コード例 #16
0
ファイル: sners.py プロジェクト: bodik/sner2
	def __init__(self, **kwargs):
        	IterableUserDict.__init__(self)
	        self.data = kwargs
		if "_id" in self:
			if self["_id"] == "":
				#*/add because add is using edit template
				del self["_id"]
			elif "$oid" in self["_id"]:
				self["_id"] = ObjectId(self["_id"]["$oid"])
			else:
				#*/edit
				self["_id"] = ObjectId(self["_id"])

		self.client = MongoClient()
		self.db = self.client[self.dbname]
		self.coll = self.db[self.collname]
コード例 #17
0
 def __init__(self, asc=True, default=0.0, *args, **kwargs):
     """
     Initialize the sparse SparseDictionary
     :param asc: whether the dictionary will be queried in ascending or descending order. Ascending corresponds
     to sender payoffs where we accumulate upwards, and descending corresponds to receiver payoffs where we are
     accumulating downwards
     :param default: The default value to return if the key does not have a value associated with it
     """
     IterableUserDict.__init__(self, *args, **kwargs)
     self.default = default
     if asc:
         self.cmp = operator.lt
     else:
         self.cmp = operator.gt
     self.history = []
     self.last_key, self.last_value = None, None
コード例 #18
0
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()
        self.auth_backends_list = [NoAuth(), BasicAuth(self)]
        if os.path.isdir('/opt/wott'):
            self.auth_backends_list.append(WoTTAuth(self))
        self.auth_backends = {}
        for backend in self.auth_backends_list:
            DEFAULTS.update(backend.config)
            self.auth_backends[backend.name] = backend

        if not path.isfile(self.conf_file):
            logging.error('Config-file %s missing. Using defaults.', self.conf_file)
            self.use_defaults()
            self.save()
        else:
            self.load()
コード例 #19
0
 def __init__(self):
     IterableUserDict.__init__(self)
     self.data['#FFFF00'] = translationBundle.get(673)
     self.data['#0000FF'] = translationBundle.get(674)
     self.data['#FFFFFF'] = translationBundle.get(675)
     self.data['#996633'] = translationBundle.get(676)
     self.data['#8B4513'] = translationBundle.get(677)
     self.data['#99FFFF'] = translationBundle.get(678)
     self.data['#00FFFF'] = translationBundle.get(679)
     self.data['#CCCCCC'] = translationBundle.get(680)
     self.data['#999999'] = translationBundle.get(681)
     self.data['#800080'] = translationBundle.get(682)
     self.data['#FF9900'] = translationBundle.get(683)
     self.data['#000000'] = translationBundle.get(684)
     self.data['#FF0000'] = translationBundle.get(685)
     self.data['#FF00FF'] = translationBundle.get(686)
     self.data['#009900'] = translationBundle.get(687)
     self.data['#006600'] = translationBundle.get(688)
コード例 #20
0
ファイル: settings.py プロジェクト: 07jetta/screenly-ose
    def __init__(self, *args, **kwargs):
        rv = IterableUserDict.__init__(self, *args, **kwargs)
        self.conf_file = path.join(CONFIG_DIR, 'screenly.conf')

        if not path.isfile(self.conf_file):
            print 'Config-file missing.'
            logging.error('Config-file missing.')
            exit(1)
        else:
            self.load()
        return rv
コード例 #21
0
ファイル: settings.py プロジェクト: jinkanban/showtime-client
    def __init__(self, *args, **kwargs):
        rv = IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            print 'Config-file %s missing' % (self.conf_file)
            exit(1)
        else:
            self.load()
        return rv
コード例 #22
0
    def __init__(self):
        IterableUserDict.__init__(self)
        # Set up couchdb.
        self._db_name = "simple-player"
        self._key = None

        self._record_type = (
            "http://wiki.ubuntu.com/Quickly/RecordTypes/SimplePlayer/"
            "Preferences")
        
        # set up signals in a separate class
        # because IterableUserDict uses self.data (documented)
        # and gtk.Invisible appears to use self.data.
        class Publisher(gtk.Invisible):
            __gsignals__ = {'changed' : (gobject.SIGNAL_RUN_LAST,
                 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
                 'loaded' : (gobject.SIGNAL_RUN_LAST,
                 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))}
        
        publisher = Publisher()
        self.emit  = publisher.emit
        self.connect  = publisher.connect
コード例 #23
0
    def __init__(self,
                 group_name=None,
                 default_target=None,
                 default_args=None,
                 default_kwargs=None,
                 default_flags=None,
                 default_kill_wait=0.5,
                 max_processes=1000,
                 process_plus_impl=None):

        self.group_name = group_name

        self._defaults = dict(target=default_target,
                              args=default_args,
                              kwargs=default_kwargs,
                              flags=self._curate_flags(default_flags),
                              kill_wait=default_kill_wait)

        self.max_processes = max_processes

        if process_plus_impl:
            assert issubclass(process_plus_impl, ProcessPlus)

        self.ProcessPlusImpl = ProcessPlus if not process_plus_impl else process_plus_impl

        self.__limbo_group = None  # Must access through property
        self.__dead_group = None  # Must access through property

        self._num_keep_dead = 100
        self._num_deleted_dead = 0

        self.logger = logging.getLogger(__name__)

        self._thread_action_loop = None
        self.stop_action = True
        self.action_loop_interval = 1  # seconds between each actions pass

        IterableUserDict.__init__(self)
コード例 #24
0
ファイル: roster.py プロジェクト: campbellr/pymacco
 def __init__(self):
     IterableUserDict.__init__(self)
     self.listeners = []
コード例 #25
0
    def __init__(self, d=None):
        if d:
            d = dict([(PBXType.Convert(k),PBXType.Convert(v)) for k,v in d.items()])

        IterableUserDict.__init__(self, d)
コード例 #26
0
 def __init__(self, dict=None):
     self._keys = []
     IterableUserDict.__init__(self, dict)
コード例 #27
0
	def __init__(self, d=None):
		if d:
			d = dict([(PBXType.Convert(k),PBXType.Convert(v)) for k,v in d.items()])

		IterableUserDict.__init__(self, d)
コード例 #28
0
ファイル: objects.py プロジェクト: a-kr/git-blamer
 def __init__(self, data=None):
     IterableUserDict.__init__(self)
     if data:
         self.data = data
コード例 #29
0
ファイル: ScanDataProcessor.py プロジェクト: openGDA/gda-core
	def __init__(self, resultDict, report):
		IterableUserDict.__init__(self, resultDict)
		self.report = report
		self.__dict__.update(resultDict)
コード例 #30
0
ファイル: device.py プロジェクト: 274914765/python
 def __init__(self):
     _IUD.__init__(self)
     self.data = MPNameCache.data
コード例 #31
0
 def __init__(self,
              rules=None,
              **kwargs):  # type: (Union[Condition,dict,None]) -> None
     IterableUserDict.__init__(self, rules, **kwargs)
コード例 #32
0
ファイル: depgraph.py プロジェクト: Zke1ev3n/miasm
 def __init__(self, dct=None):
     """Create a CacheWrapper with value @dct."""
     IterableUserDict.__init__(self, dct)
     self._nostep_cache = None
     self._nostep_keys = None
コード例 #33
0
ファイル: odict.py プロジェクト: flupke/pyflu
 def __init__(self, dict=None):
     self._keys = []
     IterableUserDict.__init__(self, dict)
コード例 #34
0
ファイル: Misc.py プロジェクト: vamsi12340/ppc64le-edk2
 def __init__(self):
     IterableUserDict.__init__(self)
     self._key_list = []
コード例 #35
0
ファイル: cidict.py プロジェクト: soldatroket/ProjetHacking
 def __init__(self, default=None):
     self._keys = {}
     IterableUserDict.__init__(self, {})
     self.update(default or {})
コード例 #36
0
ファイル: models.py プロジェクト: sammthomson/sp2014.11-731
 def __init__(self, table):
     IterableUserDict.__init__(self, table)
     self.max_foreign_len = max(len(phrase) for phrase in self.iterkeys())
コード例 #37
0
 def __init__(self):
     _IUD.__init__(self)
     self.data = MPNameCache.data
コード例 #38
0
ファイル: sners.py プロジェクト: bodik/sner3
	def __init__(self, **kwargs):
        	IterableUserDict.__init__(self)
	        self.data = kwargs

		self.coll = mdb["sners"]
コード例 #39
0
 def __init__(self, dct=None):
     """Create a CacheWrapper with value @dct."""
     IterableUserDict.__init__(self, dct)
     self._nostep_cache = None
     self._nostep_keys = None
コード例 #40
0
ファイル: ScanDataProcessor.py プロジェクト: kusamau/gda-core
 def __init__(self, resultDict, report):
     IterableUserDict.__init__(self, resultDict)
     self.report = report
     self.__dict__.update(resultDict)
コード例 #41
0
ファイル: aliasdict.py プロジェクト: LanselotOz/test-task
 def __init__(self, _dict=None):
     IterableUserDict.__init__(self)
     self.__alias = {}
     self.update(_dict)
コード例 #42
0
 def __init__ (self, dict=None):
     # Notifier slot.
     self._valuechanged = None
     IterableUserDict.__init__ (self, dict)
コード例 #43
0
ファイル: roster.py プロジェクト: dougschneider/pymacco
 def __init__(self):
     IterableUserDict.__init__(self)
     self.listeners = []
コード例 #44
0
ファイル: nagiosplugin.py プロジェクト: boosh/nagiosplugins
 def __init__(self, path):
     "Path is the path to persist data to"
     IterableUserDict.__init__(self)
     self.path = path
     self.__load()
コード例 #45
0
ファイル: queue.py プロジェクト: bodik/sner2
	def __init__(self, **kwargs):
        	IterableUserDict.__init__(self)
	        self.data = kwargs
	
		# sner queue specific
		self["workmax"] = 16
		#self["wave"] = "nowave"
		#self["params"] = "noparams"



		################ sner parameters

		##-sT - connect from userspace, nefunguje data-length
		##-sS - synscan
		#self["wave"] = "wave-test"
		#self["params"] = "-sT -p T:22,23"

		##need root
		#self["wave"] = "fast"
		#self["params"] = "-sS -sU -p T:80,23,443,21,25,49152,49154,110,445,143,8080,1025,111,993,5900,81,8443,U:631,623,161,123,138,1434,67,53,520,1900,49152,49154,69,5353,111,1812,2049,5060,1025,1433,4444,88 --min-rate 100 --max-rate 200"

		##notice -sT(userspace, slow, noudp) vs -sS -sU(root, can be fast, with udp)
		## hostgroup 16
		##       slime 14 - 16
		##       slow but detectable 100 - 200
		##       fast 1000 - 2000
		#self["wave"] = "wave1"
		#self["params"] = "-sT -A -p T:1-21,23-32768,32769-33793,48639-49633,64511-65535,U:631,623,161,123,138,1434,67,53,520,1900,49152,49154,69,5353,111,1812,2049,5060,1025,1433,4444,88,4569 --min-rate 100 --max-rate 200"

		##needs root
		#self["wave"] = "wave1rest";
		#self["params"] = "-sS -A -p T:33793-48639,49633-64511 --min-rate 2000 --max-rate 3000";


		#self["wave"] = "wave2s";
		#self["params"] = "-sT --script=safe -p T:1-32768,32769-33793,48639-49633,64511-65535 --min-rate 100 --max-rate 200";

		##needs root
		#self["wave"] = "wave1udp";
		#self["params"] = "-sU -p U:631,623,161,123,138,1434,67,53,520,1900,49152,49154,69,5353,111,1812,2049,5060,1025,1433,4444,88,4569 --min-rate 100 --max-rate 200";


		##needs root
		#self["wave"] = "wave1ext";
		#self["params"] = = "-sS -sU -A -p T:1-21,23-65535,U:631,623,161,123,138,1434,67,53,520,1900,49152,49154,69,5353,111,1812,2049,5060,1025,1433,4444,88,4569 --min-rate 700 --max-rate 1000";

		##needs root
		#self["wave"] = "wave1udpfull";
		#self["params"] = "-sU -p1-65535 --min-rate 900 --max-rate 1500";

		##needs root
		#self["wave"] = "wave1full";
		#self["params"] = "-sS -p1-65535 --min-rate 900 --max-rate 1500";


		#self["wave"] = "paranoidslime";
		###$queues['queue8']['p'] = "-sT -p T:1-21,24-32768,32769-33793,48639-49633,64511-65535 --min-rate 14 --max-rate 16";
		#self["params"] = "-sT -p T:1-21,24-32768,32769-33793,48639-49633,64511-65535 --min-rate 30 --max-rate 32";

		##needs root
		#self["wave"] = "icmpechoscan";
		#self["params"] = "-sn -PE --min-rate 14 --max-rate 16";




		################ nikto parameters

		self["wave"] = "niktobasic";
		self["workmax"] = 1
		self["params"] = "";



		self.dbname = "sner2"
		self.client = MongoClient()
		self.db = self.client[self.dbname]
		self.coll_work = self.db["work"]
		self.coll_worked = self.db["worked"]
コード例 #46
0
 def __init__(self):
     IterableUserDict.__init__(self)
     self._key_list = []
コード例 #47
0
 def __init__(self, x, y):
     IterableUserDict.__init__(self)
     self.size_x = x
     self.size_y = y
     self.all_coord = set(itertools.product(range(x), range(y)))