예제 #1
0
파일: res.py 프로젝트: team1201/tbbl
 def _copyDir(self, root, outputDir, name):
     sourcePath = os.path.join(root, name)
     destPath = os.path.join(outputDir, name)
     if os.path.isdir(sourcePath):
         self._print_copy(sourcePath, destPath)
         copy_dir(sourcePath, destPath)
     elif os.path.isfile(sourcePath):
         # Ignore py file, it maybe a tool script file.
         if not sourcePath.endswith('.py'):
             self._print_copy(sourcePath, destPath)
             shutil.copy(sourcePath, destPath)
     else:
         slog.warning('The directory [%s] is non-existence.'%sourcePath)
예제 #2
0
 def _copyDir(self, root, outputDir, name):
     sourcePath = os.path.join(root, name)
     destPath = os.path.join(outputDir, name)
     if os.path.isdir(sourcePath):
         self._print_copy(sourcePath, destPath)
         copy_dir(sourcePath, destPath)
     elif os.path.isfile(sourcePath):
         # Ignore py file, it maybe a tool script file.
         if not sourcePath.endswith('.py'):
             self._print_copy(sourcePath, destPath)
             shutil.copy(sourcePath, destPath)
     else:
         slog.warning('The directory [%s] is non-existence.' % sourcePath)
예제 #3
0
파일: base.py 프로젝트: Tiger6688/python
    def read_from_file(self, path):
        """从一个文本文件中读入信息。
        假设该文本文件的格式与 :func:`dump()` 相同。

        :param str path: 待读入的文件路径。

        """
        if not os.path.exists(path):
            slog.warning("The file %s is not exist.", path)
            return False
        txt = read_file(path)
        dic = eval(txt)
        self.copy_from_dict(dic)
        return True
예제 #4
0
파일: res.py 프로젝트: team1201/tbbl
 def _getSpecialDir(self, resType):
     lang = self.args.lang
     density = self.args.density
     vendor = self.args.vendor
     source = self.conf.getGit('resource', 'path')
     defaultDir = os.path.join(source, '%s@@@'%resType)
     if not os.path.isdir(defaultDir):
         slog.error('The directory [%s] is not existence!'%defaultDir)
         return None, None
     specialDir = os.path.join(source, '%s@%s@%s@%s'%(resType, density, lang, ''))
     if os.path.isdir(specialDir):
         return defaultDir, specialDir
     slog.warning('The directory [%s] is not existed!'%specialDir)
     return defaultDir, None
예제 #5
0
파일: update.py 프로젝트: team1201/tbbl
 def _processAGit(self, gitConf):
     print_sep('\nStart to update the git repository [%s].'%gitConf.path, True, 40)
     exists = os.path.exists(gitConf.path)
     if exists:
         if self.args.force:
             gitArgs = git.get_args(gitConf.path, 'reset', '--hard')
             slog.info(' '.join(gitArgs))
             subprocess.call(gitArgs)
         gitArgs = git.get_args(gitConf.path, 'pull', 'origin', 'master')
         slog.info(' '.join(gitArgs))
         subprocess.call(gitArgs)
         print_sep('Update the git repository [%s] has done.'%gitConf.path, False, 40)
     else:
         slog.warning('%s is not exists!'%gitConf.path)
예제 #6
0
 def _getSpecialDir(self, resType):
     lang = self.args.lang
     density = self.args.density
     vendor = self.args.vendor
     source = self.conf.getGit('resource', 'path')
     defaultDir = os.path.join(source, '%s@@@' % resType)
     if not os.path.isdir(defaultDir):
         slog.error('The directory [%s] is not existence!' % defaultDir)
         return None, None
     specialDir = os.path.join(source,
                               '%s@%s@%s@%s' % (resType, density, lang, ''))
     if os.path.isdir(specialDir):
         return defaultDir, specialDir
     slog.warning('The directory [%s] is not existed!' % specialDir)
     return defaultDir, None
예제 #7
0
파일: res.py 프로젝트: team1201/tbbl
 def _merge2Tmp(self, default, special, dirList=None):
     tempDir = tempfile.mkdtemp(prefix='tbbl_')
     slog.info("Make a temporary directory: %s", tempDir)
     print_sep('Start to merge directory [%s] and [%s] to temporary directory.'
             %(default, special))
     # Merge sub-directory one by one.
     if dirList:
         self._mergeSpecial(dirList, tempDir, default, special)
     # Merge root directory.
     else:
         if os.path.isdir(default):
             slog.warning('The directory [%s] is not existed.'%sourcePath)
             return None
         copy_dir(default, tempDir)
         copy_dir(special, tempDir)
     print_sep('Merging has done.', False)
     return tempDir
예제 #8
0
파일: update.py 프로젝트: zrong/tbbl
 def _processAGit(self, gitConf):
     print_sep('\nStart to update the git repository [%s].' % gitConf.path,
               True, 40)
     exists = os.path.exists(gitConf.path)
     if exists:
         if self.args.force:
             gitArgs = git.get_args(gitConf.path, 'reset', '--hard')
             slog.info(' '.join(gitArgs))
             subprocess.call(gitArgs)
         gitArgs = git.get_args(gitConf.path, 'pull', 'origin', 'master')
         slog.info(' '.join(gitArgs))
         subprocess.call(gitArgs)
         print_sep(
             'Update the git repository [%s] has done.' % gitConf.path,
             False, 40)
     else:
         slog.warning('%s is not exists!' % gitConf.path)
예제 #9
0
 def _merge2Tmp(self, default, special, dirList=None):
     tempDir = tempfile.mkdtemp(prefix='tbbl_')
     slog.info("Make a temporary directory: %s", tempDir)
     print_sep(
         'Start to merge directory [%s] and [%s] to temporary directory.' %
         (default, special))
     # Merge sub-directory one by one.
     if dirList:
         self._mergeSpecial(dirList, tempDir, default, special)
     # Merge root directory.
     else:
         if os.path.isdir(default):
             slog.warning('The directory [%s] is not existed.' % sourcePath)
             return None
         copy_dir(default, tempDir)
         copy_dir(special, tempDir)
     print_sep('Merging has done.', False)
     return tempDir
예제 #10
0
파일: admin.py 프로젝트: zrong/tbbl
 def toluaauto(self, bindType):
     if not self.isAdmin():
         return
     inifile = None
     cwd = self.conf.getDistPath('tolua', 'auto')
     for f in list_dir(cwd):
         if f.endswith('.ini') \
         and f.startswith('cocos2dx_') \
         and bindType in f.lower():
             inifile = f
     if inifile:
         xarg = [self.conf.getExe('python2'), 'genbindings.py', inifile]
         slog.warning('toluaauto args: %s', xarg)
         slog.warning('toluaauto target path: %s', cwd)
         py = subprocess.Popen(xarg, cwd=cwd)
         py.wait()
     else:
         slog.error('Cannot find a file named %s!' % bindType)
예제 #11
0
파일: admin.py 프로젝트: team1201/tbbl
 def toluaauto(self, bindType):
     if not self.isAdmin():
         return
     inifile = None
     cwd = self.conf.getDistPath('tolua', 'auto')
     for f in list_dir(cwd):
         if f.endswith('.ini') \
         and f.startswith('cocos2dx_') \
         and bindType in f.lower():
             inifile = f
     if inifile:
         xarg = [self.conf.getExe('python2'), 'genbindings.py', inifile]
         slog.warning('toluaauto args: %s', xarg)
         slog.warning('toluaauto target path: %s', cwd)
         py = subprocess.Popen(xarg, cwd=cwd)
         py.wait()
     else:
         slog.error('Cannot find a file named %s!'%bindType)
예제 #12
0
def convert_by_options(tpexe, options, imagefolder):
    """
    options must be a list or a string
    """
    xargs = [tpexe]
    argslist = None
    if isinstance(options, list):
        argslist = options
    elif isinstance(options, str):
        argslist = _get_args_list(options)
    if not argslist:
        slog.error("Please give some options.")
        return False
    for value in argslist:
        xargs.append(value)
    xargs.append(imagefolder)
    tpout = subprocess.check_output(xargs, universal_newlines=True)
    slog.info("Call TexturePacker, command line is: \n")
    slog.warning("%s\n", " ".join(xargs))
    slog.info("%s\n", tpout)
    return True
예제 #13
0
파일: tp.py 프로젝트: team1201/tbbl
def convert_by_options(tpexe, options, imagefolder):
    """
    options must be a list or a string
    """
    xargs = [tpexe]
    argslist = None
    if isinstance(options, list):
        argslist = options
    elif isinstance(options, str):
        argslist = _get_args_list(options)
    if not argslist:
        slog.error("Please give some options.")
        return False
    for value in argslist:
        xargs.append(value)
    xargs.append(imagefolder)
    tpout = subprocess.check_output(xargs, universal_newlines=True)
    slog.info("Call TexturePacker, command line is: \n")
    slog.warning("%s\n", " ".join(xargs))
    slog.info("%s\n", tpout)
    return True