Ejemplo n.º 1
0
def onInit():
    global RELOAD_LOCK, GIT_SUBDIR, GIT_URL_FILE, GIT_BRANCH_FILE
    RELOAD_LOCK = ReentrantLock(True)

    GIT_SUBDIR = "_local_git_cached"
    GIT_URL_FILE = "_git_url.txt"
    GIT_BRANCH_FILE = "_git_branch.txt"
    def init(self, customScript, configurationAttributes):

        if REMOTE_DEBUG:
            pydevd.settrace('localhost',
                            port=5678,
                            stdoutToServer=True,
                            stderrToServer=True)

        self.name = customScript.getName()

        print("%s: Initializing" % self.name)

        # Get the list of providers and parse into a set for quick membership tests
        providersParam = configurationAttributes.get("providers").getValue2()
        if providersParam is None:
            print("%s: Providers parameter is missing from config!" %
                  self.name)
            return False
        else:
            self.providers = set(
                [item.strip() for item in providersParam.split(",")])

        # Get the defaults for RP business rule & UI configuration
        defaultsParam = configurationAttributes.get("rp_defaults").getValue2()
        if defaultsParam is None:
            print("%s: RP defaults (rp_defaults) are missing from config!" %
                  self.name)
            return False
        else:
            try:
                self.rpDefaults = json.loads(defaultsParam)
            except ValueError:
                print("%s: failed to parse RP defaults!" % self.name)
                return False

        # Keep an in-memory cache of RP Configs
        self.rpConfigCache = {}

        self.passport = passport.Passport()
        self.passport.init(configurationAttributes, self.name)

        # Configure FIDO2
        if configurationAttributes.containsKey("fido2_server_uri"):
            print("%s: Enabling FIDO2 support" % self.name)
            self.fido2_server_uri = configurationAttributes.get(
                "fido2_server_uri").getValue2()
            self.fido2_domain = None
            if configurationAttributes.containsKey("fido2_domain"):
                self.fido2_domain = configurationAttributes.get(
                    "fido2_domain").getValue2()
            self.metaDataLoaderLock = ReentrantLock()
            self.fidoMetaDataConfiguration = None

        self.account = account.Account()

        self.telemetryClient = TelemetryClient()

        print("%s: Initialized" % self.name)
        return True
Ejemplo n.º 3
0
 def __init__(self, mpcExec = "mpc", host = None, port = None):
     self.mpcExec = mpcExec
     self.allTags = ["artist", "album", "title", "track", "name", "genre", "date", "composer", "performer", "comment", "disc", "file"]
     self.tags = ["artist", "album", "title", "track", "genre", "date", "disc", "file"]
     self.separator = "\t"
     self.host = host
     self.port = port
     self.eventLoopProcess = None
     self.lock = ReentrantLock(True)
     self.format = self.separator.join(list(map(lambda tag: "%{}%".format(tag), self.tags)))
Ejemplo n.º 4
0
    def init(self, configurationAttributes):
        print "Fido2. Initialization"

        if not configurationAttributes.containsKey("fido2_server_uri"):
            print "fido2_server_uri. Initialization. Property fido2_server_uri is not specified"
            return False

        self.fido2_server_uri = configurationAttributes.get("fido2_server_uri").getValue2()

        self.metaDataLoaderLock = ReentrantLock()
        self.metaDataConfiguration = None
        
        print "Fido2. Initialized successfully"
        return True   
Ejemplo n.º 5
0
 def getOrMakeLock(self, key):
     lock = self.locks.get(key)
     if not lock:
         # Cleanup locks
         for key in self.locks.keys():  # copy of the list of keys
             if not self.m.containsKey(key):
                 del self.locks[key]
         """
   # Proper cleanup, but unnecessary to query queued threads
   # and it is useful to keep locks for existing keys
   for key, lock in self.locks.items(): # a copy
     if not lock.hasQueuedThreads():
       del self.locks[key]
   """
         # Create new lock
         lock = ReentrantLock()
         self.locks[key] = lock
     return lock
Ejemplo n.º 6
0
 def __init__(self):
     self._lock = ReentrantLock()
     self.__owner = None
Ejemplo n.º 7
0
 def __init__(self):
     self.lock_=ReentrantLock()
Ejemplo n.º 8
0
def onInit():
    global CAMERA_LOCK
    CAMERA_LOCK = ReentrantLock(True)