Beispiel #1
0
 def test_resource_name(self):
     mywps = os.path.join(tempfile.gettempdir(), '.lazyscripts')
     env.register_workspace(mywps)
     self.assertEquals(mywps, env.resource_name())
     self.assertEquals(
         os.path.join(mywps, 'config'),
         env.resource_name('config'))
     shutil.rmtree(mywps)
Beispiel #2
0
    def _build_scripts_index(self):
        root = env.resource_name('pools')
        contents = []
        for poolname in os.listdir(root):
            poolpath = os.path.join(root, poolname)
            pool = lzspool.ScriptsPool(poolpath)
            for cat, scripts in pool.scripts(None, env.get_local()).items():
                if not scripts: continue
                for script in scripts:
                    contents.append("%s/%s/%s - %s " % (poolname, cat, script.id, script.name))

        index_path = os.path.join(env.resource_name('caches'), 'SCRIPTS_INDEX')
        with open(index_path, 'w') as f:
            f.write("\n".join(contents+['']))
Beispiel #3
0
    def _build_scripts_index(self):
        root = env.resource_name('pools')
        contents = []
        for poolname in os.listdir(root):
            poolpath = os.path.join(root, poolname)
            pool = lzspool.ScriptsPool(poolpath)
            for cat, scripts in pool.scripts(None, env.get_local()).items():
                if not scripts: continue
                for script in scripts:
                    contents.append("%s/%s/%s - %s " %
                                    (poolname, cat, script.id, script.name))

        index_path = os.path.join(env.resource_name('caches'), 'SCRIPTS_INDEX')
        with open(index_path, 'w') as f:
            f.write("\n".join(contents + ['']))
Beispiel #4
0
    def info(self):
        root = env.resource_name('pools')
        if self.argc <=  1:
            script_path = os.path.curdir;
        else:
            if pool.is_scriptspool(os.path.curdir):
                script_path = self.args[1]
            else:
                script_path = os.path.join(root, self.args[1])

        if not lzsscript.is_scriptdir(script_path):
            print "fetal: %s is not a script detectory." % script_path
            return False

        script = lzsscript.Script(script_path)
        # get attritubte.
        attrs = []
        for attr in script.parser.options('attrs'):
           if not getattr(script, attr):    continue
           attrs.append(attr)
        # get package info.
        pkginfo = script.get_pkginfo()
        _pkgs = ['-%s' % e for e in pkginfo['remove']] + \
                  ['+%s' % e for e in pkginfo['install']]
        msg_pkg = ' '.join(_pkgs)
        msg = ["Script Name: %s" % script.name,
               "Package Info: %s" % msg_pkg,
               "Support With: %s" % " ".join(attrs),
               "Script Maintaner: %s" % '\n'.join(script.maintainers),
               "Script Author: %s " % '\n'.join(script.authors),
               "Description: \n%s" % script.desc]

        print "\n".join(msg)
Beispiel #5
0
 def download_scripts (self):
     conf = env.resource('config')
     if not self.recommands_list:
         self.pool = env.resource('pool')
     else:
         path = os.path.join(env.resource_name('pools'), conf.get_default('pool'))
         self.pool = lzspool.GitScriptsPool(path, self.win.recommands_list)
Beispiel #6
0
    def info(self):
        root = env.resource_name('pools')
        if self.argc <= 1:
            script_path = os.path.curdir
        else:
            if pool.is_scriptspool(os.path.curdir):
                script_path = self.args[1]
            else:
                script_path = os.path.join(root, self.args[1])

        if not lzsscript.is_scriptdir(script_path):
            print "fetal: %s is not a script detectory." % script_path
            return False

        script = lzsscript.Script(script_path)
        # get attritubte.
        attrs = []
        for attr in script.parser.options('attrs'):
            if not getattr(script, attr): continue
            attrs.append(attr)
        # get package info.
        pkginfo = script.get_pkginfo()
        _pkgs = ['-%s' % e for e in pkginfo['remove']] + \
                  ['+%s' % e for e in pkginfo['install']]
        msg_pkg = ' '.join(_pkgs)
        msg = [
            "Script Name: %s" % script.name,
            "Package Info: %s" % msg_pkg,
            "Support With: %s" % " ".join(attrs),
            "Script Maintaner: %s" % '\n'.join(script.maintainers),
            "Script Author: %s " % '\n'.join(script.authors),
            "Description: \n%s" % script.desc
        ]

        print "\n".join(msg)
Beispiel #7
0
 def download_scripts(self):
     conf = env.resource('config')
     if not self.recommands_list:
         self.pool = env.resource('pool')
     else:
         path = os.path.join(env.resource_name('pools'),
                             conf.get_default('pool'))
         self.pool = lzspool.GitScriptsPool(path, self.win.recommands_list)
Beispiel #8
0
 def _load_pool(self, poolname):
     path = os.path.join(env.resource_name('pools'), poolname)
     if not os.path.isdir(path):
         data = self.conf.get_pool(poolname)
         os.mkdir(path)
         poolobj = pool.GitScriptsPool.init_pool(path, upstream=data['upstream'])
     else:
         poolobj = pool.GitScriptsPool(path)
     return poolobj
Beispiel #9
0
 def _load_pool(self, poolname):
     path = os.path.join(env.resource_name('pools'), poolname)
     if not os.path.isdir(path):
         data = self.conf.get_pool(poolname)
         os.mkdir(path)
         poolobj = pool.GitScriptsPool.init_pool(path,
                                                 upstream=data['upstream'])
     else:
         poolobj = pool.GitScriptsPool(path)
     return poolobj
Beispiel #10
0
 def test_add_pool(self):
     self._admin.onecmd("pool")
     path = os.path.join(env.resource_name("pools"), "zenpool")
     self._admin.onecmd("pool add zenpool")
     mypool = pool.GitScriptsPool(path)
     self.assertEquals({"origin": "", "rev": "stable", "upstream": ""}, env.resource("config").get_pool("zenpool"))
     shutil.rmtree(path)
     self._admin.onecmd("pool add zenpool /tmp/upstreampool")
     mypool = pool.GitScriptsPool(path)
     self.assertEquals(
         {"origin": "", "rev": "stable", "upstream": "/tmp/upstreampool"}, env.resource("config").get_pool("zenpool")
     )
     shutil.rmtree(path)
Beispiel #11
0
 def add(self):
     dirname = self.args[1]
     path = os.path.join(env.resource_name('pools'), dirname)
     if not os.path.isdir(path):
         os.mkdir(path)
     msg = "Creating pool %s" % dirname
     if self.argc == 3:
         msg += " remote:%s" % self.args[2]
         pool.GitScriptsPool.init_pool(path, upstream=self.args[2])
         self.conf.set_pool(dirname, upstream=self.args[2])
     else:
         pool.GitScriptsPool.init_pool(path)
         self.conf.set_pool(dirname)
     self.conf.save()
     print msg
Beispiel #12
0
 def add(self):
     dirname = self.args[1]
     path = os.path.join(env.resource_name('pools'), dirname)
     if not os.path.isdir(path):
         os.mkdir(path)
     msg = "Creating pool %s" % dirname
     if self.argc == 3:
         msg += " remote:%s" % self.args[2]
         pool.GitScriptsPool.init_pool(path, upstream=self.args[2])
         self.conf.set_pool(dirname, upstream=self.args[2])
     else:
         pool.GitScriptsPool.init_pool(path)
         self.conf.set_pool(dirname)
     self.conf.save()
     print msg
Beispiel #13
0
 def test_add_pool(self):
     self._admin.onecmd("pool")
     path = os.path.join(env.resource_name('pools'), 'zenpool')
     self._admin.onecmd("pool add zenpool")
     mypool = pool.GitScriptsPool(path)
     self.assertEquals({
         'origin': '',
         'rev': 'stable',
         'upstream': ''
     },
                       env.resource('config').get_pool('zenpool'))
     shutil.rmtree(path)
     self._admin.onecmd("pool add zenpool /tmp/upstreampool")
     mypool = pool.GitScriptsPool(path)
     self.assertEquals(
         {
             'origin': '',
             'rev': 'stable',
             'upstream': '/tmp/upstreampool'
         },
         env.resource('config').get_pool('zenpool'))
     shutil.rmtree(path)
Beispiel #14
0
 def save_selection(self):
     root = env.resource_name("log")
     filename = "%s_selection.ini" % time.time()
     sel = SelectionList(os.path.join(root, filename), self._scripts)
     sel.save()
Beispiel #15
0
 def do_search(self, lines):
     index_path = os.path.join(env.resource_name("caches"), "SCRIPTS_INDEX")
     os.system("grep %s %s" % (lines, index_path))
Beispiel #16
0
 def save_selection(self):
     root = env.resource_name('log')
     filename = "%s_selection.ini" % time.time()
     sel = SelectionList(os.path.join(root, filename), self._scripts)
     sel.save()
Beispiel #17
0
 def do_search(self, lines):
     index_path = os.path.join(env.resource_name('caches'), 'SCRIPTS_INDEX')
     os.system("grep %s %s" % (lines, index_path))