Example #1
0
def main(*args):
  maindir = '/tmp/video/'
  result_file = open('/tmp/res.html', 'w')
  for file in glob.glob(maindir + '*'):
    try: file1 = re.search('/([\w]+)\.', file).groups()[0]
    except:
      print "Not found :)"
      continue
    if file1 != '':
      result_file.write('<br><hr><br>')
      for file2 in glob.glob(maindir + 'encoded/' + file1 + '*'):
        logging.debug("File1 is %s, file2 is %s, and file is %s"%(file1, file2, file))
        result_file.write("<p>File %s compare to file %s"%(re.search('/([\w]+\.[\w]+$)', file).groups()[0], re.search('/([\w]+\.[\w]+$)', file2).groups()[0]))
        cmp = CompareVideo(file, file2)
        return_func = cmp.compare()
        logging.debug("Added to file: <p>" + return_func)
        result_file.write('<p>' + return_func)
        cmp.clean()
  result_file.close()  
Example #2
0
def save_uploaded_file (form_field, upload_dir):
    """This saves a file uploaded by an HTML form.
       The form_field is the name of the file input field from the form.
       For example, the following form_field would be "file_1":
           <input name="file_1" type="file">
       The upload_dir is the directory where the file will be written.
       If no file was uploaded or if the field does not exist then
       this does nothing.
    """
    
    if not form.has_key(form_field): return
    fileitem = form[form_field]
    if not fileitem.file: return
    path = os.path.join(upload_dir, fileitem.filename) 
    files_c.append(path)
    fout = file (path, 'wb')
    while 1:
        chunk = fileitem.file.read(100000)
        if not chunk: break
        fout.write (chunk)
    fout.close()

save_uploaded_file ("file_1", UPLOAD_DIR)
save_uploaded_file ("file_2", UPLOAD_DIR)


compare = CompareVideo(files_c[0], files_c[1])
add = compare.compare()
compare.clean()
print_html_form (add)