コード例 #1
0
    def generate(self):
        sysConf = SYSConf()
        if self.path and LocalOperation.exist(self.path):
            Log.fatal(Status["STAT_GPM_CONF_EXIST"])

            #key            prompt                         default                          verify
        sections = [("name", "project name", self.name or None, VerifyName),
                    ("language", "project language", self.language
                     or None, VerifyName),
                    ("author", "author name", self.author
                     or sysConf.author, None),
                    ("version", "initial version", self.version or 0.1, None),
                    ("email", "author email", self.email
                     or sysConf.email, VerifyEmail),
                    ("description", "project description", self.description
                     or "", None),
                    ("git_url", "git url[[email protected]:name/project.git]",
                     sysConf.git_url or None, None)]

        for section in sections:
            while (1):
                self._content[section[0]] = gets("Input %s" % section[1],
                                                 section[2])
                if section[3] and not self._content[section[0]]:
                    Log.warn(Status["STAT_INPUT_EMPTY"] % section[0])
                    continue
                elif section[3] and not VerifyName(self._content[section[0]]):
                    Log.warn(Status["STAT_INPUT_INVALID"] % section[0])
                    continue
                else:
                    break

        pkg_path = os.path.join(LocalOperation.pwd(), self.name)
        self._path = os.path.join(pkg_path, GPM_YML)
        self.write(self._path, self._content)
コード例 #2
0
 def write(self, path, data):
     LocalOperation.mkdir(os.path.dirname(path))
     with open(path, "w+") as stream:
         yaml.dump(data,
                   stream,
                   allow_unicode=True,
                   default_flow_style=False)
コード例 #3
0
ファイル: conf.py プロジェクト: galileo-project/Galileo-gpm
    def generate(self):
        sysConf = SYSConf()
        if self.path and LocalOperation.exist(self.path):
            Log.fatal(Status["STAT_GPM_CONF_EXIST"])

                      #key            prompt                         default                          verify
        sections = [("name",        "project name",                             self.name or None,               VerifyName),
                    ("language",    "project language",                         self.language or None,           VerifyName),
                    ("author",      "author name",                              self.author or sysConf.author,   None),
                    ("version",     "initial version",                          self.version or 0.1,             None),
                    ("email",       "author email",                             self.email or sysConf.email,     VerifyEmail),
                    ("description", "project description",                      self.description or "",          None),
                    ("git_url",     "git url[[email protected]:name/project.git]", sysConf.git_url or None,         None)]

        for section in sections:
            while(1):
                self._content[section[0]] = gets("Input %s" % section[1], section[2])
                if section[3] and not self._content[section[0]]:
                    Log.warn(Status["STAT_INPUT_EMPTY"] % section[0])
                    continue
                elif section[3] and not VerifyName(self._content[section[0]]):
                    Log.warn(Status["STAT_INPUT_INVALID"] % section[0])
                    continue
                else:
                    break

        pkg_path    = os.path.join(LocalOperation.pwd(), self.name)
        self._path = os.path.join(pkg_path, GPM_YML)
        self.write(self._path, self._content)
コード例 #4
0
    def find(cls, name, show = True):
        ret = LocalOperation.find(GPM_SRC, name)
        if show:
            cls.__show_pkgs(ret)

        if ret:
            conf_path = os.path.join(ret[0], GPM_YML)
            return GPMConf(conf_path), ret[0]
        return None
コード例 #5
0
    def test(self, config = None):
        self.set(config)
        ret = False
        if not self.__config:
            return False

        cmds = self.__config.test
        for cmd in cmds:
            ret = LocalOperation.run(cmd, path = self.__path)
            if not ret:
                break

        return ret
コード例 #6
0
    def install(self, config = None, save = True):
        self.set(config)
        Log.info(Status["STAT_INSTALLING_PKG"] % self.__config.name)
        ret = False
        if not self.__config:
            return False

        cmds = self.__config.install
        for cmd in cmds:
            Log.info(Status["STAT_RUN_CMD"] % cmd)
            ret = LocalOperation.run(cmd, path = self.__path)
            if not ret:
                break

        if ret and not self.__save_src(save):
            ret = False

        return ret
コード例 #7
0
ファイル: conf.py プロジェクト: galileo-project/Galileo-gpm
    def generate(self):
                      #key         prompt                                    default                        verify
        sections = [("author",  "user name",                    self.author or LocalOperation.get_user(), VerifyName),
                    ("email",   "user email",                   self.email,                               VerifyEmail),
                    ("git_url", "git url[[email protected]:name]", self.git_url,                             VerifyGit)]

        for section in sections:
            while(1):
                self._content[section[0]] = gets("Input %s" % section[1], section[2])
                if section[3] and not self._content[section[0]]:
                    Log.warn(Status["STAT_INPUT_EMPTY"] % section[0])
                    continue
                elif section[3] and not section[3](self._content[section[0]]):
                    Log.warn(Status["STAT_INPUT_INVALID"] % section[0])
                    continue
                else:
                    break

        self.write(self._path, self._content)
コード例 #8
0
    def remove(self, config=None, path=None):
        self.set(config, path)
        ret = True
        if not self.__config:
            return False

        # if self.find(self.__config.name, show = False):         #pkg exist
        #     Log.info(Status["STAT_PACKAGE_EXIST"] % self.__config.name)
        #     return False

        cmds = self.__config.remove
        for cmd in cmds:
            ret = LocalOperation.run(cmd, path = self.__path)
            if not ret:
                break

        if ret and not self.__remove_src():
            ret = False

        return ret
コード例 #9
0
    def generate(self):
        #key         prompt                                    default                        verify
        sections = [("author", "user name", self.author
                     or LocalOperation.get_user(), VerifyName),
                    ("email", "user email", self.email, VerifyEmail),
                    ("git_url", "git url[[email protected]:name]", self.git_url,
                     VerifyGit)]

        for section in sections:
            while (1):
                self._content[section[0]] = gets("Input %s" % section[1],
                                                 section[2])
                if section[3] and not self._content[section[0]]:
                    Log.warn(Status["STAT_INPUT_EMPTY"] % section[0])
                    continue
                elif section[3] and not section[3](self._content[section[0]]):
                    Log.warn(Status["STAT_INPUT_INVALID"] % section[0])
                    continue
                else:
                    break

        self.write(self._path, self._content)
コード例 #10
0
 def read(self):
     if LocalOperation.exist(self._path):
         with open(self._path, "r") as stream:
             self._content = yaml.load(stream)
コード例 #11
0
 def __init__(self, path=None):
     path = LocalOperation.rel2abs(path or SYS_CONF)
     _Conf.__init__(self, path)
コード例 #12
0
 def __save_src(self, save = True):
     if save:
         return LocalOperation.cp(self.__path, GPM_SRC)
     else:
         return True
コード例 #13
0
def _init():
    if not LocalOperation.exist(GPM_SRC):
        LocalOperation.mkdir(GPM_SRC)
コード例 #14
0
 def create_gitignore(self):
     language = self._config.language
     if language:
         content = self.github.get_gitignore_template(language)
         LocalOperation.add_file(self._GITIGNORE_NAME, content)
コード例 #15
0
 def __init__(self, path=None):
     if path and not GPM_YML in path:
         path = os.path.join(path, GPM_YML)
     path = LocalOperation.rel2abs(path or GPM_YML)
     _Conf.__init__(self, path)
コード例 #16
0
ファイル: conf.py プロジェクト: galileo-project/Galileo-gpm
 def __init__(self, path = None):
     if path and not GPM_YML in path:
         path = os.path.join(path, GPM_YML)
     path = LocalOperation.rel2abs(path or GPM_YML)
     _Conf.__init__(self, path)
コード例 #17
0
ファイル: conf.py プロジェクト: galileo-project/Galileo-gpm
 def write(self, path, data):
     LocalOperation.mkdir(os.path.dirname(path))
     with open(path, "w+") as stream:
         yaml.dump(data, stream, allow_unicode=True, default_flow_style=False)
コード例 #18
0
ファイル: conf.py プロジェクト: galileo-project/Galileo-gpm
 def read(self):
     if LocalOperation.exist(self._path):
         with open(self._path, "r") as stream:
             self._content = yaml.load(stream)
コード例 #19
0
ファイル: conf.py プロジェクト: galileo-project/Galileo-gpm
 def __init__(self, path = None):
     path = LocalOperation.rel2abs(path or SYS_CONF)
     _Conf.__init__(self, path)
コード例 #20
0
 def __init__(self, config = None, path = None):
     self.__config = config
     self.__path   = path or LocalOperation.pwd()
コード例 #21
0
 def list(cls):
     ret = LocalOperation.ls(GPM_SRC)
     cls.__show_pkgs(ret)
コード例 #22
0
ファイル: sdb.py プロジェクト: galileo-project/Galileo-gpm
 def __file_exist(self):
     db_dir = os.path.dirname(self.__path)
     if not LocalOperation.exist(db_dir):
         LocalOperation.mkdir(db_dir)
     return LocalOperation.exist(self.__path)
コード例 #23
0
 def _version(self, *args, **kwargs):
     puts(LocalOperation.distr())
     puts("%s %s" % (name, version))
コード例 #24
0
ファイル: sdb.py プロジェクト: galileo-project/Galileo-gpm
 def __file_exist(self):
     db_dir = os.path.dirname(self.__path)
     if not LocalOperation.exist(db_dir):
         LocalOperation.mkdir(db_dir)
     return LocalOperation.exist(self.__path)
コード例 #25
0
 def _version(self, *args, **kwargs):
     puts(LocalOperation.distr())
     puts("%s %s" % (name, version))
コード例 #26
0
 def __remove_src(self):
     return LocalOperation.rm(os.path.join(GPM_SRC, self.__config.name))