def git_get_hash(name, version="HEAD", path_type=None):
     if path_type is None:
         path_type = PersistentPath.git_get_type(name, version)
     if path_type == 'blob':
         cmd_list = [PersistentPath.git_command() + ["ls-files", "--stage",
                                                     str(version),
                                                     str(name)]]
         debug_print('executing commands', cmd_list)
         result, output, errs = execute_piped_cmdlines(cmd_list)
         debug_print('stdout:', type(output), output)
         debug_print('stderr:', type(errs), errs)
         if result != 0:
             # check output for error messages
             raise ModuleError(self, "Error retrieving path '%s'\n" % name +
                               errs)
         return output.split(None, 2)[1]
     elif path_type == 'tree':
         cmd_list = [PersistentPath.git_command() + ["ls-tree", "-d",
                                                     str(version),
                                                     str(name)]]
         debug_print('executing commands', cmd_list)
         result, output, errs = execute_piped_cmdlines(cmd_list)
         debug_print('stdout:', type(output), output)
         debug_print('stderr:', type(errs), errs)
         if result != 0:
             # check output for error messages
             raise ModuleError(self, "Error retrieving path '%s'\n" % name +
                               errs)
         return output.split(None, 3)[2]
     return None
示例#2
0
 def git_get_hash(name, version="HEAD", path_type=None):
     if path_type is None:
         path_type = PersistentPath.git_get_type(name, version)
     if path_type == 'blob':
         cmd_list = [
             PersistentPath.git_command() +
             ["ls-files", "--stage",
              str(version), str(name)]
         ]
         debug_print('executing commands', cmd_list)
         result, output, errs = execute_piped_cmdlines(cmd_list)
         debug_print('stdout:', type(output), output)
         debug_print('stderr:', type(errs), errs)
         if result != 0:
             # check output for error messages
             raise ModuleError(self,
                               "Error retrieving path '%s'\n" % name + errs)
         return output.split(None, 2)[1]
     elif path_type == 'tree':
         cmd_list = [
             PersistentPath.git_command() +
             ["ls-tree", "-d", str(version),
              str(name)]
         ]
         debug_print('executing commands', cmd_list)
         result, output, errs = execute_piped_cmdlines(cmd_list)
         debug_print('stdout:', type(output), output)
         debug_print('stderr:', type(errs), errs)
         if result != 0:
             # check output for error messages
             raise ModuleError(self,
                               "Error retrieving path '%s'\n" % name + errs)
         return output.split(None, 3)[2]
     return None
 def git_get_dir(name, version="HEAD", out_dirname=None, 
                 out_suffix=''):
     global temp_persist_files, tar_bin
     if out_dirname is None:
         # create a temporary directory
         out_dirname = tempfile.mkdtemp(suffix=out_suffix,
                                        prefix='vt_persist')
         temp_persist_files.append(out_dirname)
     elif not os.path.exists(out_dirname):
         os.makedirs(out_dirname)
     if systemType == "Windows":
         cmd_list = [PersistentPath.git_command() + \
                     ["archive", str(version + ':' + name)],
                 ["%s:" % out_dirname[0], "&&", "cd", "%s"%out_dirname, "&&", tar_bin, '-xf-']]
     else:
         cmd_list = [PersistentPath.git_command() + \
                     ["archive", str(version + ':' + name)],
                 [tar_bin, '-C', out_dirname, '-xf-']]
     debug_print('executing commands', cmd_list)
     result, output, errs = execute_piped_cmdlines(cmd_list)
     debug_print('stdout:', type(output), output)
     debug_print('stderr:', type(errs), errs)
     if result != 0:
         # check output for error messages
         raise ModuleError(self, "Error retrieving file '%s'\n" % name +
                           errs)
     return out_dirname
示例#4
0
 def git_get_dir(name, version="HEAD", out_dirname=None, out_suffix=''):
     global temp_persist_files, tar_bin
     if out_dirname is None:
         # create a temporary directory
         out_dirname = tempfile.mkdtemp(suffix=out_suffix,
                                        prefix='vt_persist')
         temp_persist_files.append(out_dirname)
     elif not os.path.exists(out_dirname):
         os.makedirs(out_dirname)
     if systemType == "Windows":
         cmd_list = [PersistentPath.git_command() + \
                     ["archive", str(version + ':' + name)],
                 ["%s:" % out_dirname[0], "&&", "cd", "%s"%out_dirname, "&&", tar_bin, '-xf-']]
     else:
         cmd_list = [PersistentPath.git_command() + \
                     ["archive", str(version + ':' + name)],
                 [tar_bin, '-C', out_dirname, '-xf-']]
     debug_print('executing commands', cmd_list)
     result, output, errs = execute_piped_cmdlines(cmd_list)
     debug_print('stdout:', type(output), output)
     debug_print('stderr:', type(errs), errs)
     if result != 0:
         # check output for error messages
         raise ModuleError(self,
                           "Error retrieving file '%s'\n" % name + errs)
     return out_dirname
 def git_get_type(name, version="HEAD"):
     #cmd_list = [["echo", str(version + ':' + name)],
     #            self.git_command() + ["cat-file", "--batch-check"]]
     cmd_list = [PersistentPath.git_command() + ["cat-file", "-t",
                                                 str(version + ':'+name)]]
     debug_print('executing commands', cmd_list)
     result, output, errs = execute_piped_cmdlines(cmd_list)
     debug_print('stdout:', type(output), output)
     debug_print('stderr:', type(errs), errs)
     if result != 0:
         # check output for error messages
         raise ModuleError(self, "Error retrieving file '%s'" % name +
                           errs)
     return output.split(None,1)[0]
示例#6
0
 def git_get_type(name, version="HEAD"):
     #cmd_list = [["echo", str(version + ':' + name)],
     #            self.git_command() + ["cat-file", "--batch-check"]]
     cmd_list = [
         PersistentPath.git_command() +
         ["cat-file", "-t", str(version + ':' + name)]
     ]
     debug_print('executing commands', cmd_list)
     result, output, errs = execute_piped_cmdlines(cmd_list)
     debug_print('stdout:', type(output), output)
     debug_print('stderr:', type(errs), errs)
     if result != 0:
         # check output for error messages
         raise ModuleError(self, "Error retrieving file '%s'" % name + errs)
     return output.split(None, 1)[0]