예제 #1
0
def send_log():
    logger = open("file.log", "r")
    for line in logger:
        eel.addOutput(line)
        time.sleep(0.03)

    os.remove("file.log")
예제 #2
0
def open_output_folder(folder):
    """ Open the folder of there the package was moved to """
    folder_directory = os.path.abspath(folder)  # Use absolute directories
    if platform.system() == 'Windows':
        os.startfile(folder_directory, 'explore')
    elif platform.system() == 'Linux':
        os.system('xdg-open "' + folder_directory + '"')
    elif platform.system() == 'Darwin':
        os.system('open "' + folder_directory + '"')
    else:
        eel.addOutput("Unable to open output folder: " + folder_directory)
예제 #3
0
def convert(command, output):
    eel.addOutput("Cleaning file structure\n")
    clean()
    process = subprocess.Popen(command,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    for line in iter(process.stderr.readline, ''):
        if line == b'':
            break
        eel.addOutput(line.decode('utf-8'))
    eel.addOutput("Moving project to: " + output + "\n")
    moveProject(output)
    eel.addOutput("Cleaning file structure\n")
    clean()
    eel.addOutput("Complete.\n")
    eel.outputComplete()
예제 #4
0
    def write(self, message):
        """ When sys.stderr.write is called, it will re directed here """

        # Filter pre-defined lines that don't need to be sent
        for single_filter in self.filters:
            if not single_filter.match(message) is None:
                return

        if self.ui_started:
            # Send making sure there is a newline at the end
            if message.endswith('\n'):
                eel.addOutput(message)
            else:
                eel.addOutput(message + '\n')
        else:
            self.original.write(message)
            self.original.flush()
예제 #5
0
def convert(command, output):
    eel.addOutput("Cleaning file structure\n")
    clean()

    cs.start()  # Capture stderr so PyInstaller output can be send to UI
    sys.argv = shlex.split(command)  # Put command into sys.argv
    pyi.run()  # Execute PyInstaller
    cs.stop()  # Stop stderr capture

    eel.addOutput("Moving project to: " + output + "\n")
    try:
        moveProject(output)
    except:
        eel.addOutput("Failed to move project. Did an error occur?\n")
    eel.addOutput("Cleaning file structure\n")
    clean()
    eel.addOutput("Complete.\n")
    eel.outputComplete()
예제 #6
0
def save_map_image(folder, filename, img_type):
    """
    Сохраняет изображение, помещенное в Clipboard, в файл на диске
    folder - имя папки с отчетом
    filename - имя файла с изображением
    img_type - тип изображения: 'JPEG' или 'PNG'
    """
    dst_path = os.path.join(settings.REPORTS_PATH, folder, 'images')
    print(f'>>> Путь к папке с картинками: {dst_path}')
    if os.path.exists(dst_path):
        img_file = os.path.join(dst_path, filename)
        print(f'save_map_image: файл {img_file} \n')
        time.sleep(1)  # без этой задержки берет из clipboard предыдущее содержимое
        img = ImageGrab.grabclipboard()  # from PIL import ImageGrab
        # eel.addOutput(f'save_map_image: файл {img_file} \n')
        img.save(img_file, img_type)   # img_type: 'JPEG' или 'PNG'
    else:
        print(f'*** save_map_image: папка {dst_path} не существует\n')
        eel.addOutput(f'*** save_map_image: папка {dst_path} не существует\n')
        logging.debug(f'*** save_map_image: папка {dst_path}не существует\n')
예제 #7
0
def create_bhpassport(folder):
    global area
    print(f'Адрес: {area.address}')
    logging.debug(f'Адрес: {area.address}')
    print(f'Папка с паспортом: {folder}')
    logging.debug(f'Папка с паспортом: {folder}')

    # Копируем папку с шаблоном отчета в папку с изысканиями
    dst_path = os.path.join(settings.BHPASSPORTS_PATH, folder)
    print(f'Путь к папке с отчетом: {dst_path}')
    logging.debug(f'Путь к папке с отчетом: {dst_path}')
    eel.addOutput(f'>>> Копируем шаблон отчета в папку {dst_path}\n')
    err = cadastron.copy_template_folder(settings.TEX_BH_TEMPLATE_PATH, dst_path)
    if not err:
        eel.addOutput('>>> Шаблон скопирован\n')

        # Заменим в файле шаблона bhpassport.tex адрес, кад. номер и номенклатуру на реальные
        fname = os.path.join(dst_path, settings.TEX_BH_TEMPLATE_FILE)
        cadastron.modify_tex_file(fname, area.address, area.cadaster, area.nomenclature, area.coords)

        # Откроем проводник в папке назначения
        webbrowser.open(dst_path)
    else:
        eel.addOutput(f'*** Ошибка копирования: {err}\n')
        logging.debug(f'*** Ошибка копирования: {err}\n')
예제 #8
0
def create_report(folder, addr):
    global area

    if addr:
        area.address = addr

    print('Адрес:', area.address)
    print('Папка с отчетом:', folder)

    # Копируем папку с шаблоном отчета в папку с изысканиями
    dst_path = os.path.join(settings.REPORTS_PATH, folder)
    print('Путь к папке с отчетом:', dst_path)
    eel.addOutput('>>> Копируем шаблон отчета в папку {0}\n'.format(dst_path))
    err = cadastron.copy_template_folder(settings.TEX_TEMPLATE_PATH, dst_path)
    if not err:
        eel.addOutput('>>> Шаблон скопирован\n')

        # Заменим в файле шаблона water.tex адрес, кад. номер и номенклатуру на реальные
        fname = os.path.join(dst_path, settings.TEX_TEMPLATE_FILE)
        cadastron.modify_tex_file(fname, area.address, area.cadaster, area.nomenclature, area.coords)

        # Откроем проводник в папке назначения
        webbrowser.open(dst_path)
    else:
        eel.addOutput('*** Ошибка копирования: {0}\n'.format(err))
예제 #9
0
def load_info_by_coords(coords, address):
    global area
    print('Входная строка 1(координаты) %s' % coords)
    print('Входная строка 2 %s' % address)
    (lat, lon) = cadastron.parse_coords(coords)
    print('Lat {} Lon {}'.format(lat, lon))

    eel.print_to_textarea_js('Получение информации по координатам...')

    area = cadastron.get_info_by_coords(lat, lon, address)

    if not area.errmsg:
        # eel.print_to_textarea_js(area.brief)
        eel.print_to_textarea_js(area.info)
        eel.print_to_url_js(area.yandex_url)
        eel.enable_btn_yandex_js()
        eel.enable_btn_create_js()
        eel.print_to_input_report_js(cadastron.gen_report_folder(area.address))
        eel.print_to_input_bhpassport_js(cadastron.gen_bhpassport_folder(area.address))
        cadastron.make_ozi_file(settings.OZI_WAYPOINTS_FILE, area.ozi_info)
        eel.addOutput('>>> Создаем файл Ozi Waypoints\n')
        eel.setYmapPosition_js(area.lat, area.lon, 12, '')
        eel.set_ymap_src_js(area.yandex_url_static)
        eel.setGeoMapPosition_js(area.lat, area.lon)
        eel.print_nomenclature_js('Лист ' + area.nomenclature)

        eel.addOutput('>>> Latitude  : {0}\n'.format(area.lat))
        eel.addOutput('>>> Longitude : {0}\n'.format(area.lon))

    else:
        eel.print_to_textarea_js(area.errmsg)
예제 #10
0
def load_info(x):
    print('Введенный кад. номер: {}'.format(x))
    cadno = cadastron.parse_cadaster(x)
    global area
    eel.print_to_textarea_js('Идет поиск...')
    eel.turn_spinner_js('1') # Запустим спиннер на кнопке Старт

    area = cadastron.get_info(cadno)

    if not area.errmsg:
        # eel.print_to_textarea_js(area.brief)
        eel.print_to_textarea_js(area.info)
        eel.print_to_url_js(area.yandex_url)
        eel.enable_btn_yandex_js()
        eel.enable_btn_create_js()
        eel.print_to_input_report_js(cadastron.gen_report_folder(area.address))
        eel.print_to_input_bhpassport_js(cadastron.gen_bhpassport_folder(area.address))
        cadastron.make_ozi_file(settings.OZI_WAYPOINTS_FILE, area.ozi_info)
        eel.addOutput('>>> Создаем файл Ozi Waypoints\n')
        eel.setYmapPosition_js(area.lat, area.lon, 12, area.cadaster)
        eel.set_ymap_src_js(area.yandex_url_static)
        eel.setGeoMapPosition_js(area.lat, area.lon)
        eel.print_nomenclature_js('Лист ' + area.nomenclature)

        eel.addOutput('>>> Latitude  : {0}\n'.format(area.lat))
        eel.addOutput('>>> Longitude : {0}\n'.format(area.lon))

    else:
        eel.print_to_textarea_js(area.errmsg)
 
    eel.turn_spinner_js('0')  # Остановим спиннер на кнопке Старт
예제 #11
0
def create_report(folder, addr, phone):
    global area

    if addr:
        area.address = addr

    print(f'Адрес:{area.address}')
    logging.debug(f'Адрес:{area.address}')
    print(f'Телефон:{phone}')
    logging.debug(f'Телефон:{phone}')
    print(f'Папка с отчетом:{folder}')
    logging.debug(f'Папка с отчетом:{folder}')

    # Копируем папку с шаблоном отчета в папку с изысканиями
    dst_path = os.path.join(settings.REPORTS_PATH, folder)
    print(f'Путь к папке с отчетом:{dst_path}')
    eel.addOutput(f'>>> Копируем шаблон отчета в папку {dst_path}\n')
    err = cadastron.copy_template_folder(settings.TEX_TEMPLATE_PATH, dst_path)
    if not err:
        eel.addOutput('>>> Шаблон скопирован\n')

        # Заменим в файле шаблона water.tex адрес, кад. номер и номенклатуру на реальные
        fname = os.path.join(dst_path, settings.TEX_TEMPLATE_FILE)
        cadastron.modify_tex_file(fname, area.address, area.cadaster, area.nomenclature, area.coords, phone)

        # Запишем информацию в файл реестра отчетов
        today = date.today()
        curr_date = today.strftime("%d-%b-%Y")
        reestr_rec = f'{curr_date};{addr};{area.cadaster};{phone}\n'
        print(f'Запись в реестр: {reestr_rec}')
        cadastron.make_reestr_file(settings.REESTR_FILE, reestr_rec)

        # Откроем проводник в папке назначения
        webbrowser.open(dst_path)
    else:
        eel.addOutput(f'*** Ошибка копирования: {err}\n')
        logging.debug(f'*** Ошибка копирования: {err}\n')
예제 #12
0
def convert(command, output, disable_recursion_limit):
    """ Package the executable passing the arguments the user requested """
    eel.addOutput("Running auto-py-to-exe v" + version)
    # Notify the user of the workspace and setup building to it
    eel.addOutput(
        "Building in the current instances temporary directory at {}\n".format(
            temporary_directory))
    eel.addOutput(
        "To get a new temporary directory, restart this application\n")
    dist_path = os.path.join(temporary_directory, 'application')
    build_path = os.path.join(temporary_directory, 'build')
    extra_args = ['--distpath', dist_path] + ['--workpath', build_path] + [
        '--specpath', temporary_directory
    ]

    # If the Recursion Limit is enabled, set it
    if not disable_recursion_limit:
        sys.setrecursionlimit(5000)
        eel.addOutput("Recursion Limit is set to 5000\n")
    else:
        sys.setrecursionlimit(
            DEFAULT_RECURSION_LIMIT
        )  # In the case the limit was set and now the user doesn't want it set

    # Run PyInstaller
    pyinstaller_fail = True
    cs.start()  # Capture stderr so PyInstaller output can be send to UI
    sys.argv = shlex.split(
        command) + extra_args  # Put command into sys.argv and extra args
    try:
        eel.addOutput("Executing: {0}\n".format(command))
        pyi.run()  # Execute PyInstaller
        pyinstaller_fail = False
    except:
        eel.addOutput("An error occurred, traceback follows:\n")
        eel.addOutput(traceback.format_exc())
    cs.stop()  # Stop stderr capture

    # Move project if there was no failure
    if pyinstaller_fail:
        eel.addOutput("\n")
        eel.addOutput("Project output will not be moved to output folder\n")
    else:
        output_directory = os.path.abspath(output)  # Use absolute directories
        eel.addOutput("Moving project to: {0}\n".format(output_directory))
        try:
            move_project(dist_path, output_directory)
        except:
            eel.addOutput("Failed to move project, traceback follows:\n")
            eel.addOutput(traceback.format_exc())

    eel.addOutput("Complete.\n")
    eel.outputComplete()
예제 #13
0
def convert(command, output):
    """ Package the executable passing the arguments the user requested """
    # Initially clean the workspace
    eel.addOutput("Cleaning workspace\n")
    try:
        clean()
    except Exception as e:
        eel.addOutput("Warning: could not clean the workspace before starting\n")

    # Run PyInstaller
    pyinstaller_fail = True
    cs.start() # Capture stderr so PyInstaller output can be send to UI
    sys.argv = shlex.split(command) # Put command into sys.argv
    try:
        pyi.run() # Execute PyInstaller
        pyinstaller_fail = False
    except Exception as e:
        eel.addOutput("An error occured, traceback follows:\n")
        eel.addOutput(traceback.format_exc())
    cs.stop() # Stop stderr capture

    # Move Project
    if pyinstaller_fail:
        eel.addOutput("\n")
        eel.addOutput("Project output will not be moved to output folder\n")
    else:
        eel.addOutput("Moving project to: " + output + "\n")
        try:
            moveProject(output)
        except Exception as e:
            eel.addOutput("Failed to move project, traceback follows:\n")
            eel.addOutput(traceback.format_exc())

    # Clean the workspace
    eel.addOutput("Cleaning workspace\n")
    try:
        clean()
    except Exception as e:
        eel.addOutput("Warning: could not clean the workspace; some build files will still exist\n")

    eel.addOutput("Complete.\n")
    eel.outputComplete()
예제 #14
0
def convert(command, output):
    eel.addOutput("Cleaning file structure\n")
    clean()
    process = subprocess.Popen(command,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    for line in iter(process.stderr.readline, ''):
        if line == b'':
            break
        eel.addOutput(line.decode('utf-8', errors='replace'))
    eel.addOutput("Moving project to: " + output + "\n")
    try:
        moveProject(output)
    except:
        eel.addOutput("Failed to move project. Did an error occur?\n")
    eel.addOutput("Cleaning file structure\n")
    clean()
    eel.addOutput("Complete.\n")
    eel.outputComplete()