def update_script(py_script):
    py3_path = 'c:\\python35\\python.exe'
    # py_script = ''
    os.system(
        py3_path+' '+py_script
    )
    sg.Popup('更新完成!\n按OK结束'.decode('gbk'))
    pass
def kernel_dwg_to_shp(params):
    arcgis_python,input_python_script,input_dir,out_dir = params

    os.system(
        arcgis_python.encode('gbk') + ' ' +
        input_python_script.encode('gbk') + ' ' +
        input_dir.encode('gbk') + ' ' +
        out_dir.encode('gbk')
    )
    sg.Popup('dwg转shp完毕!\n按OK结束'.decode('gbk'))
    pass
Ejemplo n.º 3
0
def kernel_mapping(params):
    arcgis_python,mapping_script,fdir,out_pic_dir,heng_template,shu_template = params
    os.system(
        arcgis_python.encode('gbk') + ' ' +
        mapping_script.encode('gbk') + ' ' +
        fdir.encode('gbk') + ' ' +
        out_pic_dir.encode('gbk') + ' ' +
        heng_template.encode('gbk') + ' ' +
        shu_template.encode('gbk')
    )
    sg.Popup('制图完毕!\n按OK结束'.decode('gbk'))
    pass
def merge():
    if os.path.isfile(os.getcwd() + '\\merge_config.cfg'):
        config_r = open(os.getcwd() + '\\merge_config.cfg', 'r')
        lines = config_r.readlines()
        param_dic = {}
        for line in lines:
            line = line.split('\n')
            para = line[0].split('=')[0]
            val = line[0].split('=')[1]
            param_dic[para] = val
        # if 'fdir' in param_dic:
        try:
            sg_input_dir = sg.Input(param_dic['fdir'].decode('gbk'))
            sg_input_out_dir = sg.Input(param_dic['out_dir'].decode('gbk'))
        except:
            sg_input_out_dir = sg.Input('')
            sg_input_dir = sg.Input('')
    else:
        sg_input_out_dir = sg.Input('')
        sg_input_dir = sg.Input('')
    layout1 = [[sg.Text('输入需要合并的文件夹'.decode('gbk'))],
               [sg_input_dir, sg.FolderBrowse()],
               [sg.Text('输出目录'.decode('gbk'))],
               [sg_input_out_dir, sg.FolderBrowse()],
               [sg.OK()] ]
    window1 = sg.Window('合并图层'.decode('gbk'),font=("Helvetica", 20)).Layout(layout1)

    while 1:

        event1, values1 = window1.Read()
        if event1 is None:
            break
        # print(values1)
        indir = values1[0]
        outdir = values1[1]
        print(indir)
        print(outdir)
        # exit()
        config = codecs.open(os.getcwd() + '\\' + 'merge_config.cfg', 'w')
        config.write('fdir=' + indir.encode('gbk') + '\n')
        config.write('out_dir=' + outdir.encode('gbk') + '\n')
        config.close()
        indir = indir.encode('gbk')
        outdir = outdir.encode('gbk')
        merge_shp.Merge().merge(indir,outdir)
        # yongcheng.Merge().merge_point_annotation_shp(indir,outdir)
        # yongcheng.Merge().merge_daoxian(indir,outdir)
        # yongcheng.main(fdir+'/',f_excel)
        sg.Popup('图层生成完毕!\n按OK结束'.decode('gbk'))
        window1.Close()
        break
def kernel_gen_layer(fdir,f_excel):
    yongcheng.main(fdir + '/', f_excel)
    sg.Popup('图层生成完毕!\n按OK结束'.decode('gbk'))

    pass
Ejemplo n.º 6
0
def kernel_gen_layer(fdir, f_excel, additional_excel):
    genshp_ver3.gen_layer(fdir, f_excel, additional_excel)
    sg.Popup('图层生成完毕!\n按OK结束'.decode('gbk'))
    pass
Ejemplo n.º 7
0
def main():

    valid_input = []
    for i in range(10):
        valid_input.append(str(i))
    valid_input.append(':')
    valid_input.append('.')
    # print(valid_input)
    # exit()
    text = sg.Text('input IP or domain and port', auto_size_text=1, font=Font)

    text1 = sg.Text('select IP and port', auto_size_text=1, font=Font)
    sg_input = sg.Input()

    fr = open('ipconfig.txt')
    lines = fr.readlines()
    fr.close()
    listbox = []
    for line in lines:
        line = line.split('\n')[0]
        listbox.append(line)

    sg_listbox = sg.Listbox(listbox, size=(40, 10), font=Font)
    layout1 = [[text], [sg_input], [text1], [sg_listbox],
               [sg.OK(), sg.Cancel()]]

    window1 = sg.Window('proxy').Layout(layout1)

    while 1:
        event1, values1 = window1.Read()
        if event1 == None:
            break
        break_flag = 0
        # for str_ in values1[0]:
        #     if str_ not in valid_input:
        #         sg.Popup(u'输入有误', title=u'错误', font=Font)
        #         break_flag = 1
        #         break

        if len(values1[0]) == len(values1[1]) == 0:
            sg.Popup(u'请选择', title=u'错误', font=Font)
            continue
        if break_flag == 1:
            sg_input.Update('')
            continue

        if len(values1[0]) > 0:
            # print(1)
            ip = values1[0]
        else:
            ip = values1[1][0]
            # sg_input.Update(ip)
        if ip == 0 or ip == 'clear':
            clear_proxy()
        else:
            set_proxy(ip)
        sg_input.Update('')
        # print(ip)
        # print(values1)

        # print(ip)
    pass
Ejemplo n.º 8
0
def main():

    text = sg.Text(
        '请输入视频网址(例如:http://532movie.bnu.edu.cn/movie/3981.html)\n或输入搜索关键词(例如: 周星驰 或 喜剧之王):'
        .decode('utf-8'),
        auto_size_text=1,
        font=Font)
    layout1 = [
        [text],
        [sg.Input(), sg.OK(u'搜索')],
    ]

    window1 = sg.Window('Download 532 Movies').Layout(layout1)

    # win2_active = 0
    while 1:
        event1, values1 = window1.Read()
        if not check_connection():
            sg.PopupError(u'连接错误\n请检查网络是否能连接 532movie.bnu.edu.cn',
                          title=u'错误',
                          font=Font)
            continue
        if event1 is None:
            break
        print(values1)
        key_word = values1[0]
        if len(key_word) < 2:
            sg.Popup('请多于2个关键词'.decode('utf-8'))
            continue

        if key_word.startswith('http'):
            movie_name, _ = get_vedio_url(key_word)
            movie_name = [movie_name]
            urls = [key_word]
        else:
            movie_name, urls = search(key_word)
        # key_word = key_word.encode('utf-8')
        for i in movie_name:
            print(i)
        movie_dic = {}
        listbox = []
        for i in range(len(movie_name)):
            movie_dic[movie_name[i].decode('utf-8')] = urls[i]
            listbox.append(movie_name[i].decode('utf-8'))

        if len(movie_name) > 0 and not event1 is None:
            # listbox = movie_name
            sg_listbox = sg.Listbox(listbox, size=(50, 10), font=Font)
            text1 = u'%s\n 搜索结果:共有%s条,请选择要下载的影片' % (key_word, len(movie_name))
            if os.path.isfile(os.getcwd() + '\\config.cfg'):
                config_r = open(os.getcwd() + '\\config.cfg', 'r')
                lines = config_r.readlines()
                param_dic = {}
                for line in lines:
                    line = line.split('\n')
                    para = line[0].split('=')[0]
                    val = line[0].split('=')[1]
                    param_dic[para] = val
                if 'movie_path' in param_dic:
                    sg_input = sg.Input(param_dic['movie_path'])
                else:
                    sg_input = sg.Input('')
            else:
                sg_input = sg.Input('')
            layout2 = [[sg.Text(text1, font=Font)], [sg_listbox,
                                                     sg.OK(u'下载')],
                       [sg.Text(u'下载路径', font=Font)],
                       [sg_input, sg.FolderBrowse(u'浏览')]]

            window2 = sg.Window(u'搜索结果').Layout(layout2)
            while 1:
                ev2, vals2 = window2.Read()
                if ev2 is None:
                    window2.Close()
                    break
                if len(vals2[0]) == 0:
                    sg.Popup(u'请选择一个电影', title=u'错误', font=Font)
                    continue
                # print(vals2[0][0])
                url = movie_dic[vals2[0][0]]
                # print(url)
                # print(vals2)
                movie_path = vals2[1]
                if len(movie_path) == 0:
                    sg.Popup(u'请输入下载路径', title=u'错误', font=Font)
                    continue
                # print(movie_path)
                config = open(os.getcwd() + '\\config.cfg', 'w')
                config.write('movie_path=' + movie_path + '\n')
                config.close()
                # sg_input.Update(movie_path)
                # movie_path = os.getcwd()+'\\'
                movie_path = movie_path + '/'

                print(movie_path)
                # exit()
                download_movies(url, movie_path)

        else:
            sg.Popup(u'无搜索结果,请检查关键词', title=u'错误', font=Font)

        if event1 is None:
            break
Ejemplo n.º 9
0
def download_movies(url, movie_path):
    '''
    :param url: 'http://532movie.bnu.edu.cn/player/3379.html'
    :return: None
    download *.ts to RAM
    write mp4 movie file to local disk from RAM
    '''
    temp_file = str(time.time())
    try:
        codecs.open(movie_path + temp_file, 'wb')
    except:
        sg.Popup(u'路径错误', font=Font)
        return None
    os.remove(movie_path + temp_file)
    movie_name, urls = get_vedio_url(url)
    invalid_char = '/\:*"<>|?'
    for ic in invalid_char:
        if ic in movie_name:
            movie_name = movie_name.replace(ic, '.')
    print(movie_name)
    # try:
    #     print(movie_name.decode('utf-8').encode('utf-8','ignore'))
    # except:
    #     print(movie_name.split()[0].decode('utf-8').encode('utf-8','ignore'))
    #
    try:
        movie_name_utf8 = movie_name.decode('utf-8').encode('gbk', 'ignore')
    except:
        movie_name_utf8 = movie_name.split()[0].decode('utf-8').encode(
            'gbk', 'ignore')
    episode = 0
    flag = 0
    # time_init = time.time()

    # time_start = time.time()
    if len(urls) == 1:
        if os.path.isfile(movie_path + movie_name.decode('utf-8') + '.mp4'):
            # print(movie_path + movie_name_utf8 + '.mp4 is already existed')
            sg.Popup(movie_path + movie_name.decode('utf-8') + u'已存在',
                     font=Font)
            return None
        ts = split_videos(urls[0])

        pool = ThreadPool(20)
        # bar_fmt = 'Downloading\t' + '|{bar}|{percentage:3.0f}%'
        results = list(tqdm_gui(pool.imap(download_ts, ts), total=len(ts)))
        plt.title('asdf')
        pool.close()
        pool.join()
        # print('Writing to disk...')
        movie = codecs.open(movie_path + movie_name_utf8 + '.mp4', 'wb')
        bar_fmt1 = 'writing to disk\t' + '|{bar}|{percentage:3.0f}%'
        for i in tqdm(range(len(results)), bar_format=bar_fmt1, ncols=50):
            movie.write(results[i])
        movie.close()

        plt.close()
        sg.Popup(u'下载完成!', title=u'完成', font=Font)

    else:

        # episode_str = raw_input(
        #     'there are %s episodes, please input a series of numbers like this(e.g.:1,10,15 or 1-3,4-10)' % len(urls))

        text = sg.Text(u'共有%s集\n请输入集数\n(例如:1,10,15 or 1-3,4-10)\n直接点击下载所有' %
                       len(urls),
                       auto_size_text=1,
                       font=Font)
        layout = [
            [text],
            [sg.Input(), sg.OK(u'下载')],
        ]
        window = sg.Window(u'选择集数').Layout(layout)
        while 1:

            ev, vals = window.Read()
            if ev is None:
                break
            # episodes = episode_str.split(',')
            print(vals)
            # continue
            if len(vals[0]) == 0:
                selected = range(1, len(urls) + 1)
            else:
                episodes = vals[0].split(',')

                selected = []
                fail1 = 0
                try:
                    for e in episodes:
                        if '-' in e:
                            e_split = e.split('-')
                            e_start = e_split[0]
                            e_end = e_split[1]
                            ee = range(int(e_start), int(e_end) + 1)
                            for ei in ee:
                                selected.append(ei)
                        else:
                            selected.append(int(e))
                except:
                    fail1 = 1

                selected.sort()
                for s in selected:
                    if s > len(urls):
                        print('there are no episode %s' % s)
                        fail1 = 1
                    elif s < 1:
                        print('input error...')
                        fail1 = 1
                if fail1 == 1:
                    sg.PopupError(u'输入有误', title=u'错误', font=Font)
                    continue

            # print selected
            # continue
            text2 = sg.Text('')
            layout2 = [
                [text2],
                [
                    sg.ProgressBar(len(selected),
                                   orientation='h',
                                   size=(20, 20),
                                   key='progressbar')
                ],
            ]
            window2 = sg.Window(u'下载进度').Layout(layout2)
            progress_bar = window2.FindElement('progressbar')

            flag1 = 0
            for i in urls:

                ev2, va2 = window2.Read(timeout=0)
                if ev2 is None:
                    break
                # selected_episodes = range(1, int(1e5))
                text2.Update(i)
                episode += 1
                if episode not in selected:
                    continue
                TV_dir = movie_path + movie_name_utf8 + '\\'
                if not os.path.isdir(TV_dir):
                    os.makedirs(TV_dir)
                if os.path.isfile(TV_dir + 'Episode ' + '%02d' % episode +
                                  '.mp4'):
                    # print(TV_dir + 'Episode ' + '%02d' % episode + '.mp4 is already existed')
                    flag += 1
                    # continue
                    sg.Popup(movie_name.decode('utf-8') + 'Episode ' +
                             '%02d' % episode + u'已存在',
                             font=Font)
                    continue
                pool = ThreadPool(20)
                ts = split_videos(i)
                bar_fmt = 'Episode %02d' % episode + '|{bar}|{percentage:3.0f}%'
                results = list(
                    tqdm_gui(pool.imap(download_ts, ts),
                             total=len(ts),
                             ncols=50,
                             bar_format=bar_fmt))
                pool.close()
                pool.join()
                plt.close()
                movie = codecs.open(
                    TV_dir + 'Episode ' + '%02d' % episode + '.mp4', 'wb')
                for r in results:
                    movie.write(r)
                progress_bar.UpdateBar(flag1 + 1)
                flag1 += 1
                window2.Close()