예제 #1
0
def face_swap():
    data = request.get_json()

    if 'image' not in data:
        return "", 400
    elif 'templete' not in data:
        return "", 400
    main.convert(data['image'], data['templete'])
예제 #2
0
 def __init__(self, master=None):
     Frame.__init__(self, master)
     master.title("Python 3.5 translator")
     master.minsize(width=220, height=100)
     master.maxsize(width=400, height=200)
     master.iconbitmap(r'icon/python.ico')
     self.pack(side="top")
     filepath = self.createWidgets()
     convert(filepath)
     print("Convert-method returned: ", filepath)
예제 #3
0
파일: test.py 프로젝트: llxzy/file-compress
    def test_first(self):
        # tests conversion
        input_path = "./tests/first/"
        self.assertTrue(len(os.listdir(input_path)) == 1)
        self.assertTrue(os.path.exists(input_path + "a"))
        convert(input_path)
        self.assertTrue(len(os.listdir(input_path)) == 1)
        self.assertTrue(os.path.exists(input_path + "a.gz"))
        self.assertFalse(os.path.exists(input_path + "a"))

        #cleanup
        os.remove(input_path + "a.gz")
        create_file(input_path + "a")
예제 #4
0
def get_link():
    link = link_var.get()
    print(link)
    mp = tkvar_mp.get()
    link_type = tkvar_link.get()

    if link_type == "video":
        main.download_vid(link, path)
        if mp == "mp3":
            main.convert(path)
    else:
        main.download(link, path)
        if mp == "mp3":
            main.convert(path)
예제 #5
0
def getEqu_frmfile(path):
    try:
        result = " "
        value = 0
        Ouput_path = "output/Outputdoc.txt"
        intermediateResult = " "
        matchingTags = r"begin{equation}(.*?)end{equation}"
        #print("Opening a file...")
        Inputfile = open(path, "r")
        Inputstr = Inputfile.read()
        #print("Reading done")
        matches = re.finditer(matchingTags, Inputstr, re.MULTILINE | re.DOTALL)
        #print("Matching string")
        file_wr(Ouput_path, result)
        for matchNum, match in enumerate(matches):

            for groupNum in range(0, len(match.groups())):
                intermediateResult = match.group(1)

                file_write(Ouput_path, "Equation %d:" % (value + 1))
                print("intermediateResult:")
                print(intermediateResult)
                result = convert(intermediateResult)
                print("Result:")
                print(result)

                file_write(Ouput_path, result)
                value += 1
        Inputfile.close()
        #print(result)
        print("terminated reading mode")
        return result
    except Exception as e:
        print("Exception:")
        print(e)
예제 #6
0
파일: gui.py 프로젝트: anandhupvr/labelcvt
    def convert(self):
        self.progress.grid(row=6, column=1)
        self.progress.start(5)
        lfmt = "xml"
        ifmt = "jpg"
        res = ensure.ensure(self.directory, ifmt, lfmt)

        if res == "OK":
            print("Everything loooks good!")
            main.update_cat_names(self.directory)
            main.convert(self.directory)
            print("Here")
            self.progressingBar()
        else:
            print(res)
        self.yolo.configure(state="normal")
예제 #7
0
def lip():
    data = request.get_json()

    if 'image' not in data:
        return "", 400
    elif 'templete' not in data:
        return "", 400
    elif 'audio' not in data:
        return "", 400
    main.convert(data['image'], data['templete'])

    file = base64.b64decode(data['audio'])

    audio_path = './demo_file/voice.wav'
    wav_file = open(audio_path, "wb")
    wav_file.write(file)
    wav2_main(output_path, audio_path)
예제 #8
0
파일: test.py 프로젝트: llxzy/file-compress
    def test_second(self):
        #tests ignoring already zipped files and directories
        input_path = "./tests/second/"
        self.assertTrue(len(os.listdir(input_path)) == 3)
        self.assertTrue(os.path.exists(input_path + "c"))
        self.assertTrue(os.path.exists(input_path + "a.gz"))
        self.assertTrue(os.path.isdir(input_path + "b"))
        convert(input_path)
        self.assertTrue(len(os.listdir(input_path)) == 3)
        self.assertTrue(os.path.exists(input_path + "c.gz"))
        self.assertFalse(os.path.exists(input_path + "c"))
        self.assertTrue(os.path.exists(input_path + "a.gz"))
        self.assertTrue(os.path.isdir(input_path + "b"))
        print(os.path.exists(input_path + "c"))

        #cleanup
        os.remove(input_path + "c.gz")
        create_file(input_path + "c")
예제 #9
0
def convert():

    out = main.convert(
        request.args.get('input_currency'),
        request.args.get('output_currency'),
        float(request.args.get('amount'))
    )

    return out
예제 #10
0
파일: cli.py 프로젝트: fore-stack/vshift
def interface(analyze=True, convert=True, prompt=False, benchmark=False):

    import main

    if benchmark:
        # @Benchmark Mode

        main.benchmark()

    elif prompt:
        # @Prompt Mode

        mode = click.prompt('Choose mode (analysis, conversion)', type=str)

        if mode == 'analysis':

            source = click.prompt('Enter source audio path 🎧 ', type=str)

            target = click.prompt('Enter target audio path 🔊 ', type=str)

            main.analyze(source, target)

        elif mode == 'conversion':

            matrices = click.prompt('Enter matrices path 🔢 ', type=str)

            original = click.prompt('Enter audio path 🎧 ', type=str)

            main.convert(matrices, original)

        else:

            click.secho('Error: Invalid Mode ✘', fg='red')

    else:

        # @Default Mode
        if len(analyze) == 2:

            main.analyze(analyze[0], analyze[1])

        elif len(convert) == 2:

            main.convert(convert[0], convert[1])
def test_duration():

    ins = main.convert()
    names = ins.multiconvert()
    for name in names:
        induration, outduration = ins.ffprobe(name[0], name[1])
        assert induration == approx(outduration)
        induration, outduration = ins.ffprobe(name[0], name[2])
        assert induration == approx(outduration)
    print("All files are converted successfully!")
예제 #12
0
def backfill():
    models = [m[1] for m in fsdb.get_models()]

    import dual_net
    import tensorflow as tf
    from tqdm import tqdm
    features, labels = dual_net.get_inference_input()
    dual_net.model_fn(features, labels, tf.estimator.ModeKeys.PREDICT,
                      dual_net.get_default_hyperparams())

    for model_name in tqdm(models):
        if model_name.endswith('-upgrade'):
            continue
        try:
            load_file = os.path.join(fsdb.models_dir(), model_name)
            dest_file = os.path.join(fsdb.models_dir(), model_name)
            main.convert(load_file, dest_file)
        except:
            print('failed on', model_name)
            continue
예제 #13
0
 def _equals(self, arabic, roman):
     self.assertEqual(main.convert(arabic), roman)
예제 #14
0
import main

# Testing soil weight est
result1 = main.soil_weight_est(1.0, 'kPa', 'psf')
result2 = main.soil_weight_est(.01, 'MPa', 'psf')
result3 = main.soil_weight_est(1.0, 'psi', 'psf')

# Testing Corrected Cone Resistance
result1 = main.corrected_cone_resistance(3000, 0)
result2 = main.corrected_cone_resistance(250, 10)

# Testing Effective Overburden Pressure
result1 = main.effective_overburden_pressure(117.2,
                                             11,
                                             above_pressure=1445,
                                             depth_below_water_table=6,
                                             units='english')
result1 = main.convert(result1, 'psf', 'psi')
here = ""
예제 #15
0
def executetxt(Input):
    result = convert(Input)
    readtxt(result)
예제 #16
0
def getfrm_txtbox(Input):
    result = convert(Input)
    return result
예제 #17
0
 def test_convert(self):
     self.assertEqual(convert(1), 'A')
     self.assertEqual(convert(2), 'B')
     self.assertEqual(convert(26), 'Z')
     self.assertEqual(convert(27), 'AA')
     self.assertEqual(convert(28), 'AB')
     self.assertEqual(convert(29), 'AC')
     self.assertEqual(convert(30), 'AD')
     self.assertEqual(convert(52), 'AZ')
     self.assertEqual(convert(53), 'BA')
     self.assertEqual(convert(676), 'YZ')
     self.assertEqual(convert(677), 'ZA')
     self.assertEqual(convert(703), 'AAA')
     self.assertEqual(convert(717), 'AAO')
     self.assertEqual(convert(728), 'AAZ')
     self.assertEqual(convert(729), 'ABA')
     self.assertEqual(convert(730), 'ABB')
     self.assertEqual(convert(18278), 'ZZZ')
예제 #18
0
from main import convert

assert convert('12.02.3') == None

assert convert('') == None

assert convert('12.5325.3 12:32:21') == None

assert convert(
    '12.02.3 12:32:21'
) == 'двенадцатое февраля третьего года двенадцать часов тридцать две минуты двадцать одна секунда'

assert convert(
    '15.11.13 01:15:01'
) == 'пятнадцатое ноября тринадцатого года ноль один час пятнадцать минут ноль одна секунда'

assert convert(
    '13.09.913 01:05:11'
) == 'тринадцатое сентября девятьсот тринадцатого года ноль один час ноль пять минут одиннадцать секунд'

assert convert(
    '09.12.2913 23:53:54'
) == 'девятое декабря две тысячи девятьсот тринадцатого года двадцать три часа пятьдесят три минуты пятьдесят четыре секунды'

assert convert(
    '28.07.3913 09:13:45'
) == 'двадцать восьмое июля три тысячи девятьсот тринадцатого года ноль девять часов тринадцать минут сорок пять секунд'

assert convert(
    '17.04.2019 06:26:27'
) == 'семнадцатое апреля две тысячи девятнадцатого года ноль шесть часов двадцать шесть минут двадцать семь секунд'
예제 #19
0
 def test_conversion(self):
     with open("testdata.json", "r") as outfile:
         test_data = json.load(outfile)
     for input, expected in test_data:
         self.assertEqual(expected, main.convert(input))
예제 #20
0
 def test1(self):
     self.assertEqual(main.convert("65"),"A")
예제 #21
0
 def testShouldNotConvertWith10(self):
     self.assertNotEqual(convert(11), 3650)
예제 #22
0
 def testShouldReturnAnException(self):
     """
   Test convert receiving an integer string
 """
     self.assertEqual(convert("oi"), "Please inform a valid number")
예제 #23
0
파일: gui.py 프로젝트: Letractively/vdown
 def download_single(
                     self,
                     widget,
                     event = None
                    ):
     entry_url = self.wTree.get_widget("entry_url")
     pb = self.wTree.get_widget("dprogressbar")
     mainDownload_button = self.wTree.get_widget("mainDownload_button")
     mainClose_button = self.wTree.get_widget("mainClose_button")
     url = entry_url.get_text()
     os.chdir(
              self.config.get(
                              "general",
                              "save_videos_in"
                             )
             )
     pb.set_fraction(0)
     pb.set_text(_("Fetching video information..."))
     if url == "":
         pb.set_text(_("No URL specified"))
     else:
         print "----"
         print _("Trying to download %(url)s") % {"url" : url}
         pb.set_fraction(0)
         mainDownload_button.set_sensitive(False)
         mainClose_button.set_sensitive(False)
         data = get_data(url)
         data.start()
         while data.status == -1:
             gtk.main_iteration_do(False)
             sleep(0.01)
         gtk.main_iteration_do(True)
         if data.status == 0:
             saveAs = os.path.join(
                                   self.config.get(
                                                   "general",
                                                   "save_videos_in"
                                                  ),
                                   data.data[2]
                                  )
             print "Saving file as \"%(filename)s\"..." % {"filename" : saveAs}
             down = fdownload(
                              data.data[0],
                              data.data[2]
                             )
             down.start()
             pb.set_fraction(0)
             pb.set_text(_("Downloading video..."))
             progress = down.downloaded()/100
             while down.get_filesize() == 0:
                 gtk.main_iteration_do(False)
                 sleep(0.01)
             gtk.main_iteration_do(True)
             filesize = down.get_filesize()
             print "Filesize: %(filesize)s KB" % {"filesize" : filesize}
             while progress < 1:
                 gtk.main_iteration_do(False)
                 sleep(0.01)
                 pb.set_fraction(progress)
                 progress = down.downloaded()/100
             gtk.main_iteration_do(True)
             pb.set_fraction(1)
             pb.set_text(_("Download finished."))
             if self.config.getboolean(
                                       "general",
                                       "convert"
                                      ) and data.data[3]:
                 pb.set_text(_("Converting file"))
                 output = convert(
                                  saveAs,
                                  self.config.get(
                                                  "general",
                                                  "convert_filename_extension"
                                                 ),
                                  self.config.get(
                                                  "general",
                                                  "convertcmd"
                                                 )
                                 )
                 output.start()
                 while output.status == -1:
                     gtk.main_iteration_do(False)
                     sleep(0.01)
                 gtk.main_iteration_do(True)
                 pb.set_text(_("Converted file."))
                 if self.config.getboolean(
                                           "general",
                                           "delete_source_file_after_converting"
                                          ):
                     os.remove(saveAs)
                     print _("Deleted input (.flv) file")
         else:
             pb.set_text(_("Wrong URL / unsupported video portal"))
         mainDownload_button.set_sensitive(True)
         mainClose_button.set_sensitive(True)
         print "----"
예제 #24
0
 def testShouldConvertWithInteger(self):
     """
   Test convert receiving an integer value
 """
     self.assertEqual(convert(10), 3650)
예제 #25
0
 def test2(self):
     self.assertEqual(main.convert("656667"),"ABC")
예제 #26
0
파일: gui.py 프로젝트: Letractively/vdown
 def download_list(self): # Clicked on button 'open' in filechooserdialog
     self.listdownloading = True
     fc = self.wTree.get_widget("filechooserdialog")
     pb = self.wTree.get_widget("dprogressbar")
     mainDownload_button = self.wTree.get_widget("mainDownload_button")
     mainClose_button = self.wTree.get_widget("mainClose_button")
     os.chdir(
              self.config.get(
                              "general",
                              "save_videos_in"
                             )
             )
     fc.hide()
     pb.set_fraction(0)
     chosen_list = fc.get_filename()
     print "%(list)s selected" % {"list" : chosen_list}
     print "-----"
     mainDownload_button.set_sensitive(False)
     mainClose_button.set_sensitive(False)
     pb.set_text(_("Downloading a list..."))
     file = open(
                 chosen_list,
                 "r"
                )
     i = 0
     successful = 0 # videos downloaded successfully
     while True:
         pb.set_fraction(0)
         pb.set_text(_("Fetching video information..."))
         line = file.readline()
         if not line:
             break
         if line[-1] == "\n":
             line = line[:-1]
         print "----"
         print _("Trying to download %(link)s") % {"link" : line}
         v_no = i+1 # example: You're downloading the v_no. video && You're downloading the 5. video
         data = get_data(line)
         data.start()
         while data.status == -1:
             gtk.main_iteration_do(False)
             sleep(0.01)
         gtk.main_iteration_do(True)
         if data.status == 0:
             saveAs = os.path.join(
                                   self.config.get(
                                                   "general",
                                                   "save_videos_in"
                                                  ),
                                   data.data[2]
                                  )
             print _("Saving file as \"%(filename)s\"...") % {"filename" : saveAs}
             down = fdownload(
                              data.data[0], # http://*.*/*
                              data.data[2]  # .flv
                             )
             down.start()
             pb.set_text(_("Downloading video %(number)s") % {"number" : v_no})
             progress = down.downloaded()/100
             while down.get_filesize() == 0:
                 gtk.main_iteration_do(False)
                 sleep(0.01)
             gtk.main_iteration_do(True)
             filesize = down.get_filesize()
             print _("Filesize: %(filesize)s KB") % {"filesize" : filesize}
             while progress < 1:
                 gtk.main_iteration_do(False)
                 sleep(0.005)
                 pb.set_fraction(progress)
                 progress = down.downloaded()/100
             gtk.main_iteration_do(True)
             pb.set_fraction(1)
             pb.set_text(_("Finished download #%(number)s") % {"number" : v_no})
             successful += 1
             if self.config.getboolean(
                                       "general",
                                       "convert"
                                      ) and data.data[3]:
                 pb.set_text(_("Converting file"))
                 output = convert(
                                  saveAs,
                                  self.config.get(
                                                  "general",
                                                  "convert_filename_extension"
                                                 ),
                                  self.config.get(
                                                  "general",
                                                  "convertcmd"
                                                 )
                                 )
                 output.start()
                 while output.status == -1:
                     gtk.main_iteration_do(False)
                     sleep(0.01)
                 gtk.main_iteration_do(True)
                 pb.set_text(_("Converted file."))
                 if self.deletesourcefile:
                     os.remove(saveAs)
                     print _("Deleted input (.flv) file")
         else:
             print _("Wrong URL / unsupported video portal")
             pb.set_text(_("Download #%(number)s failed") % {"number" : v_no})
         i += 1
         print "----"
     pb.set_text(_("%(successful)s of %(all)s successful") % {"successful" : successful, "all" : i})
     mainDownload_button.set_sensitive(True)
     mainClose_button.set_sensitive(True)
     self.listdownloading = False
     print "-----"
예제 #27
0
 def test3(self):
     self.assertEqual(main.convert("676584"),"CAT")
예제 #28
0
 def test4(self):
     self.assertEqual(main.convert("73327673756932858080698267658369"),"I LIKE UPPERCASE")
예제 #29
0
 def testShouldConvertWith10(self):
     self.assertEqual(convert(10), 3650)