def run(self, para=None):
        url = para['repo']
        if 'github.com' in url:
            if url[-4:] == '.git':
                url = url.replace('.git', '/archive/master.zip')
            elif url[-4:] != '.zip':
                url = url + '/archive/master.zip'
            domain, name = url.split('/')[-4:-2]
        else:
            domain, name = (url[:-4].replace('.', '-')).split('/')[-2:]
        domain, name = domain.replace('_', '-'), name.replace('_', '-')

        IPy.set_info('downloading plugin from %s' % para['repo'])
        urlretrieve(url,
                    os.path.join(path_cache, domain + '_' + name + '.zip'),
                    lambda a, b, c, p=self: Schedule(a, b, c, p))
        zipf = zipfile.ZipFile(
            os.path.join(path_cache, domain + '_' + name + '.zip'))
        folder = zipf.namelist()[0]
        zipf.extractall(path_cache)
        destpath = os.path.join(path_plgs,
                                domain + '_' + folder.replace('-master', ''))
        if os.path.exists(destpath): shutil.rmtree(destpath)
        os.rename(os.path.join(path_cache, folder), destpath)
        zipf.close()
        IPy.set_info('installing requirement liberies')
        self.prgs = (None, 1)
        cmds = [
            sys.executable, '-m', 'pip', 'install', '-r',
            '%s/requirements.txt' % destpath
        ]
        subprocess.call(cmds)
        IPy.reload_plgs(True, True, True, True)
Example #2
0
 def on_remove(self, event):
     i = self.lst_plgs.GetFirstSelected()
     if i == -1: return
     shutil.rmtree(self.buf[i][-1]['folder'])
     IPy.reload_plgs(True, True, True, True)
     self.load()
Example #3
0
 def run(self, para=None):
     IPy.reload_plgs(True, True, True, True)