Esempio n. 1
0
 def updateUASCache(self, req):
     Log.Debug('Starting to update the UAS Cache')
     # Main call
     try:
         # Start by getting the time stamp for the last update
         lastUpdateUAS = Dict['UAS']
         Log.Debug('Last update time for UAS Cache is: %s' %
                   (lastUpdateUAS))
         if lastUpdateUAS == None:
             # Not set yet, so default to Linux start date
             lastUpdateUAS = datetime.datetime.strptime(
                 '01-01-1970 00:00:00', '%m-%d-%Y %H:%M:%S')
         else:
             lastUpdateUAS = datetime.datetime.strptime(
                 str(lastUpdateUAS), '%Y-%m-%d %H:%M:%S.%f')
         # Now get the last update time from the UAS repository on GitHub
         masterUpdate = datetime.datetime.strptime(
             self.getLastUpdateTime(req, True, self.UAS_URL),
             '%Y-%m-%d %H:%M:%S')
         # Do we need to update the cache, and add 2 min. tolerance here?
         if (masterUpdate -
                 lastUpdateUAS) > datetime.timedelta(seconds=120):
             # We need to update UAS Cache
             # Target Directory
             targetDir = Core.storage.join_path(self.PLUGIN_DIR,
                                                NAME + '.bundle', 'http',
                                                'uas')
             # Force creation, if missing
             Core.storage.ensure_dirs(targetDir)
             # Grap file from Github
             zipfile = Archive.ZipFromURL(self.UAS_URL +
                                          '/archive/master.zip')
             for filename in zipfile:
                 # Walk contents of the zip, and extract as needed
                 data = zipfile[filename]
                 if not str(filename).endswith('/'):
                     # Pure file, so save it
                     path = self.getSavePath(targetDir, filename)
                     Log.Debug('Extracting file' + path)
                     try:
                         Core.storage.save(path, data)
                     except Exception, e:
                         bError = True
                         Log.Debug("Unexpected Error")
                 else:
                     # We got a directory here
                     Log.Debug(filename.split('/')[-2])
                     if not str(filename.split('/')[-2]).startswith('.'):
                         # Not hidden, so let's create it
                         path = self.getSavePath(targetDir, filename)
                         Log.Debug('Extracting folder ' + path)
                         try:
                             Core.storage.ensure_dirs(path)
                         except Exception, e:
                             bError = True
                             Log.Debug("Unexpected Error")
             # Update the AllBundleInfo as well
             pms.updateAllBundleInfoFromUAS()
             pms.updateUASTypesCounters()
Esempio n. 2
0
        def saveInstallInfo(url, bundleName):
            # Get the dict with the installed bundles, and init it if it doesn't exists
            if not 'installed' in Dict:
                Dict['installed'] = {}

            # Start by loading the UAS Cache file list
            jsonFileName = Core.storage.join_path(self.PLUGIN_DIR,
                                                  NAME + '.bundle', 'http',
                                                  'uas', 'Resources',
                                                  'plugin_details.json')
            json_file = io.open(jsonFileName, "rb")
            response = json_file.read()
            json_file.close()
            # Convert to a JSON Object
            gits = JSON.ObjectFromString(str(response))
            bNotInUAS = True
            # Walk the one by one, so we can handle upper/lower case
            for git in gits:
                if url.upper() == git['repo'].upper():
                    key = git['repo']
                    del git['repo']
                    git['date'] = datetime.datetime.now().strftime(
                        "%Y-%m-%d %H:%M:%S")
                    Dict['installed'][key] = git
                    bNotInUAS = False
                    Log.Debug(
                        'Dict stamped with the following install entry: ' +
                        key + ' - ' + str(git))
                    # Now update the PMS-AllBundleInfo Dict as well
                    Dict['PMS-AllBundleInfo'][key] = git
                    pms.updateUASTypesCounters()
                    break
            if bNotInUAS:
                key = url
                pFile = Core.storage.join_path(self.PLUGIN_DIR, bundleName,
                                               'Contents', 'Info.plist')
                pl = plistlib.readPlist(pFile)
                git = {}
                git['title'] = bundleName[bundleName.rfind("/"):][1:][:-7]
                git['description'] = ''
                git['branch'] = ''
                git['bundle'] = bundleName[bundleName.rfind("/"):][1:]
                git['identifier'] = pl['CFBundleIdentifier']
                git['type'] = ['Unknown']
                git['icon'] = ''
                git['date'] = datetime.datetime.now().strftime(
                    "%Y-%m-%d %H:%M:%S")
                Dict['installed'][key] = git
                # Now update the PMS-AllBundleInfo Dict as well
                Dict['PMS-AllBundleInfo'][key] = git
                Log.Debug('Dict stamped with the following install entry: ' +
                          key + ' - ' + str(git))
                pms.updateUASTypesCounters()
            Dict.Save()
            return
Esempio n. 3
0
             'type']
         targetGit['icon'] = uasListjson[git][
             'icon']
         targetGit['date'] = dtStamp
         targetGit['supporturl'] = uasListjson[git][
             'supporturl']
         Dict['installed'][git] = targetGit
         Log.Debug(
             'Dict stamped with the following install entry: '
             + git + ' - ' + str(targetGit))
         # Now update the PMS-AllBundleInfo Dict as well
         Dict['PMS-AllBundleInfo'][git] = targetGit
         Dict.Save()
         migratedBundles[git] = targetGit
         bFound = True
         pms.updateUASTypesCounters()
         break
 if not bFound:
     Log.Debug('Found %s is sadly not part of uas' %
               (pluginDir))
     vFile = Core.storage.join_path(
         self.PLUGIN_DIR, pluginDir, 'Contents',
         'VERSION')
     if os.path.isfile(vFile):
         Log.Debug(
             pluginDir +
             ' is an official bundle, so skipping')
     else:
         git = {}
         git['title'] = pluginDir[:-7]
         git['description'] = ''