def __load(self, filename):
     self.standard_values = {}
     for standard, pattern in self.standards.iteritems():
         self.standard_values[standard] = {}
     encoded_filename = self.__encodeFilename(filename)
     command = [self.exif_runtime, "-G", "-charset", self.config["exif"]["charset"], encoded_filename]
     p = subprocess.Popen(
         command, shell=self.config["exif"]["shell"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
     )
     for line in p.stdout.readlines():
         # print line.decode("utf-8").rstrip('\n')
         for standard, pattern in self.standards.iteritems():
             cline = self.__cleanLine(line)
             match = pattern.match(cline)
             if match:
                 self.standard_values[standard][match.group(1).replace(" ", "").replace("/", "")] = match.group(2)
                 break
         if self.__verbose:
             if "[File]          File Name " in cline and isWindows():
                 print str(cline.decode("cp1252"))
             elif "[File]          Directory" in cline and isWindows():
                 print str(cline.decode("cp1252"))
             else:
                 print str(cline)
     p.wait()
def loadFoldersToDB(root_directory):
    c=0
    for root_directory, dirs, files in os.walk(root_directory): #@UnusedVariable
        if len(files) != 0:
            c += 1
            if isWindows():
                mroot = root_directory.decode('cp1252')
            else:
                mroot = root_directory
            print "%4d %-100s %5d" % (c, shortenDisplay(mroot), len(files))
            af = AssetFolder(path = mroot, asset_count = len(files), last_scanned = timezone.now())
            af.save()
            print "-" * 150
 def __init__(self):
     self.config = {}
     rconfig = loadYamlConfig(__file__, 'test_data_config.yml')
     if isWindows():
         path = rconfig['data_path']['windows']
         self.output_path = rconfig['output_path']['windows']
     elif isMac():
         path = rconfig['data_path']['mac']
         self.output_path = rconfig['output_path']['mac']
     else:
         raise Exception('Unsupported Operating system for TestConfig')
     for name, fn in rconfig['files'].iteritems():
         self.config[name] = os.path.join(path, fn)
 def __encodeFilename(self, filename):
     encoded_filename = filename
     if isWindows():
         strfn = str(filename)
         encoded_filename = strfn.encode("cp1252")
     return encoded_filename