Esempio n. 1
0
 def run(self):
     """build_qt"""
     try:
         import pyqt5ac
         pyqt5ac.main(ioPaths=[
             [str(here/'**/qt/*.qrc'), '%%DIRNAME%%/%%FILENAME%%.py'],
             ])
     except ModuleNotFoundError as exception:
         raise ModuleNotFoundError('Missing Qt auto-compiler, please try: pip install pyqt5ac')
Esempio n. 2
0
def create_archive(
    parameters: Parameters,
    release_version: str,
    archive_name: str,
    add_translations: bool = False,
    allow_uncommitted_changes: bool = False,
    is_prerelease: bool = False,
    raise_min_version: str = None,
    disable_submodule_update: bool = False,
):

    repo = git.Repo()

    top_tar_handle, top_tar_file = mkstemp(suffix=".tar")

    # keep track of current state
    initial_stash = None
    diff = repo.index.diff(None)
    if diff:
        print("Uncommitted changes:")
        for diff in diff:
            print(diff)
        if not allow_uncommitted_changes:
            raise UncommitedChanges(
                "You have uncommitted changes. Stash or commit them or use --allow-uncommitted-changes."
            )
        else:
            initial_stash = repo.git.stash("create")

    # changelog
    if parameters.changelog_include:
        parser = ChangelogParser(parameters.changelog_regexp)
        if parser.has_changelog():
            try:
                content = parser.last_items(
                    parameters.changelog_number_of_entries)
                if content:
                    replace_in_file(
                        "{}/metadata.txt".format(parameters.plugin_path),
                        r"^changelog=.*$",
                        "changelog={}".format(content),
                    )
            except Exception as e:
                # Do not fail the release process if something is wrong when parsing the changelog
                replace_in_file(
                    "{}/metadata.txt".format(parameters.plugin_path),
                    r"^changelog=.*$",
                    "",
                )
                print(
                    "An exception occurred while parsing the changelog file : {}"
                    .format(e))
    else:
        # Remove the changelog line
        replace_in_file("{}/metadata.txt".format(parameters.plugin_path),
                        r"^changelog=.*$", "")

    # set version in metadata
    replace_in_file(
        "{}/metadata.txt".format(parameters.plugin_path),
        r"^version=.*$",
        "version={}".format(release_version),
    )

    # set the plugin as experimental on a pre-release
    if is_prerelease:
        replace_in_file(
            "{}/metadata.txt".format(parameters.plugin_path),
            r"^experimental=.*$",
            "experimental={}".format(True if is_prerelease else False),
        )

    if raise_min_version:
        replace_in_file(
            "{}/metadata.txt".format(parameters.plugin_path),
            r"^qgisMinimumVersion=.*$",
            "qgisMinimumVersion={}".format(raise_min_version),
        )

    # replace any DEBUG=False in all Python files
    if not is_prerelease:
        for file in glob("{}/**/*.py".format(parameters.plugin_path),
                         recursive=True):
            replace_in_file(file, r"^DEBUG\s*=\s*True", "DEBUG = False")

    # keep track of current state
    try:
        stash = repo.git.stash("create")
    except git.exc.GitCommandError:
        stash = "HEAD"
    if stash == "" or stash is None:
        stash = "HEAD"
    # create TAR archive
    print("archive plugin with stash: {}".format(stash))
    repo.git.archive(stash, "-o", top_tar_file, parameters.plugin_path)
    # adding submodules
    for submodule in repo.submodules:
        _, sub_tar_file = mkstemp(suffix=".tar")
        if submodule.path.split("/")[0] != parameters.plugin_path:
            print("skipping submodule not in plugin source directory ({})".
                  format(submodule.name))
            continue
        if not disable_submodule_update:
            submodule.update(init=True)
        sub_repo = submodule.module()
        print("archive submodule:", sub_repo)
        sub_repo.git.archive("HEAD", "--prefix", "{}/".format(submodule.path),
                             "-o", sub_tar_file)
        with tarfile.open(top_tar_file, mode="a") as tt:
            with tarfile.open(sub_tar_file, mode="r:") as st:
                for m in st.getmembers():
                    # print('adding', m, m.type, m.isfile())
                    if not m.isfile():
                        continue
                    tt.add(m.name)

    # add translation files
    if add_translations:
        with tarfile.open(top_tar_file, mode="a") as tt:
            print("adding translations")
            for file in glob("{}/i18n/*.qm".format(parameters.plugin_path)):
                print("  adding translation: {}".format(
                    os.path.basename(file)))
                # https://stackoverflow.com/a/48462950/1548052
                tt.add(file)

    # compile qrc files
    pyqt5ac.main(ioPaths=[[
        "{}/*.qrc".format(parameters.plugin_path),
        "{}/%%FILENAME%%_rc.py".format(parameters.plugin_path),
    ]])
    for file in glob("{}/*_rc.py".format(parameters.plugin_path)):
        with tarfile.open(top_tar_file, mode="a") as tt:
            print("  adding resource: {}".format(file))
            # https://stackoverflow.com/a/48462950/1548052
            tt.add(file)

    # converting to ZIP
    # why using TAR before? because it provides the prefix and makes things easier
    with zipfile.ZipFile(file=archive_name,
                         mode="w",
                         compression=zipfile.ZIP_DEFLATED) as zf:
        # adding the content of TAR archive
        with tarfile.open(top_tar_file, mode="r:") as tt:
            for m in tt.getmembers():
                if m.isdir():
                    continue
                f = tt.extractfile(m)
                fl = f.read()
                fn = m.name
                zf.writestr(fn, fl)

    print("-------")
    print("files in ZIP archive ({}):".format(archive_name))
    with zipfile.ZipFile(file=archive_name, mode="r") as zf:
        for f in zf.namelist():
            print(f)
    print("-------")

    # checkout to reset changes
    if initial_stash:
        repo.git.reset("--hard", initial_stash)
        repo.git.reset("HEAD^")
    else:
        repo.git.checkout("--", ".")
Esempio n. 3
0
from PyQt5.QtCore import *
from PyQt5 import QtCore
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import *

debug = False
if debug:
    import pyqt5ac

    pyqt5ac.main(config='config.yml')

from Widgets import VirtualNumpad_ui


class VirtualNumpad(QDialog, VirtualNumpad_ui.Ui_VirtualNumpad):
    def __init__(self,
                 parent=None,
                 parentLineEdit=None,
                 signalFromParentLineEdit=None):
        super(VirtualNumpad, self).__init__(parent)
        self.setupUi(self)

        # self.leftArrowButton.setIcon(QIcon('./Icons/left_arrow.png'))
        # self.rightArrowButton.setIcon(QIcon('./Icons/right_arrow.png'))

        self.parentLineEdit = parentLineEdit
        self.setAttribute(QtCore.Qt.WA_StyledBackground, True)
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents, False)
        #self.setStyleSheet("background-color: black;")
        self.setGeometry(0, 0, 800, 480)
Esempio n. 4
0
import rawpy
import imageio
from PIL import Image
import shutil

from PyQt5 import uic, QtCore
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog
from PyQt5.QtCore import Qt, QThreadPool
import pyqt5ac

from modules import build, threading, models

# =============================================================================
# APP SETUP
# =============================================================================
pyqt5ac.main(config='resources/resources config.yml')
app_id = 'AstroSorter.AstroSorter.AstroSorter.AstroSorter'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
form_class = uic.loadUiType('gui/astrosorter.ui')[0]
app = QApplication(sys.argv)


# =============================================================================
# MAIN CLASS
# =============================================================================
class AstroSorter(QMainWindow, form_class):
    def __init__(self, parent=None):
        # Build the main GUI
        QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self.show()
Esempio n. 5
0
lg.addHandler(lu.SQLiteHandler())
""" Generando GUI desde archivo dialog.ui"""
gui_file = os.path.join(script_path, "dialog.ui")
gui_py_path = os.path.join(script_path, "dialog.py")
input_path = os.path.join("C:\\", "SIMEC")
output_path = os.path.join("C:\\", "SIMEC", "TPL", "salida")
resource_path = os.path.join(script_path, "resources")
resource_py_path = os.path.join(script_path, "resource_rc.py")
""" Añadiendo algunos recursos a la variable PATH"""
sys.path.append(resource_path)

# transformando el GUI a código Python:
pyqt5ac.main(
    rccOptions='',
    force=False,
    config='',
    ioPaths=[[script_path + '/*.ui', script_path + '/%%FILENAME%%.py'],
             [resource_path + '/*.qrc',
              resource_path + '/%%FILENAME%%_rc.py']])

# procesando información en paralelo:
lst_th = list()
to_process = dict()
# importando los archivos generados:
from gui.dialog import Ui_MainWindow
from gui import DF_Window

# Table order:
c_select = 0
c_archive = 1
c_action = 3
import sys

from util import constants

# If debugging application then automatically generate the UI if necessary
if constants.debug:
    import pyqt5ac

    pyqt5ac.main(config='pyqt5ac_config.yml')

from gui.mainWindow import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

# Back up the reference to the exceptionhook
sys._excepthook = sys.excepthook

# Exception hook is used to print out the exception
# This is necessary for Qt 5 applications because Qt uses an event loop which will not trigger a traceback
def customExceptionHook(exctype, value, traceback):
    # Print the error and traceback
    print(exctype, value, traceback)

    # Call the normal Exception hook after
    sys._excepthook(exctype, value, traceback)
    sys.exit(1)


# Set the exception hook to our wrapping function
sys.excepthook = customExceptionHook
Esempio n. 7
0
def create_archive(parameters: Parameters,
                   release_version: str,
                   archive_name: str,
                   add_translations: bool = False,
                   allow_uncommitted_changes: bool = False,
                   is_prerelease: bool = False,
                   raise_min_version: str = None):

    repo = git.Repo()

    top_tar_handle, top_tar_file = mkstemp(suffix='.tar')

    # keep track of current state
    initial_stash = None
    diff = repo.index.diff(None)
    if diff:
        print("Uncommitted changes:")
        for diff in diff:
            print(diff)
        if not allow_uncommitted_changes:
            raise UncommitedChanges(
                'You have uncommitted changes. Stash or commit them or use --allow-uncommitted-changes.'
            )
        else:
            initial_stash = repo.git.stash('create')

    # set version in metadata
    replace_in_file('{}/metadata.txt'.format(parameters.plugin_path),
                    r'^version=.*$', 'version={}'.format(release_version))

    # set the plugin as experimental on a pre-release
    if is_prerelease:
        replace_in_file(
            '{}/metadata.txt'.format(parameters.plugin_path),
            r'^experimental=.*$',
            'experimental={}'.format(True if is_prerelease else False))

    if raise_min_version:
        replace_in_file('{}/metadata.txt'.format(parameters.plugin_path),
                        r'^qgisMinimumVersion=.*$',
                        'qgisMinimumVersion={}'.format(raise_min_version))

    # replace any DEBUG=False in all Python files
    if not is_prerelease:
        for file in glob('{}/**/*.py'.format(parameters.plugin_path),
                         recursive=True):
            replace_in_file(file, r'^DEBUG\s*=\s*True', 'DEBUG = False')

    # keep track of current state
    try:
        stash = repo.git.stash('create')
    except git.exc.GitCommandError:
        stash = 'HEAD'
    if stash == '' or stash is None:
        stash = 'HEAD'
    # create TAR archive
    print('archive plugin with stash: {}'.format(stash))
    repo.git.archive(stash, '-o', top_tar_file, parameters.plugin_path)
    # adding submodules
    for submodule in repo.submodules:
        _, sub_tar_file = mkstemp(suffix='.tar')
        if submodule.path.split('/')[0] != parameters.plugin_path:
            print('skipping submodule not in plugin source directory ({})'.
                  format(submodule.name))
            continue
        submodule.update(init=True)
        sub_repo = submodule.module()
        print('archive submodule:', sub_repo)
        sub_repo.git.archive('HEAD', '--prefix', '{}/'.format(submodule.path),
                             '-o', sub_tar_file)
        with tarfile.open(top_tar_file, mode="a") as tt:
            with tarfile.open(sub_tar_file, mode="r:") as st:
                for m in st.getmembers():
                    # print('adding', m, m.type, m.isfile())
                    if not m.isfile():
                        continue
                    tt.add(m.name)

    # add translation files
    if add_translations:
        with tarfile.open(top_tar_file, mode="a") as tt:
            print("adding translations")
            for file in glob('{}/i18n/*.qm'.format(parameters.plugin_path)):
                print('  adding translation: {}'.format(
                    os.path.basename(file)))
                # https://stackoverflow.com/a/48462950/1548052
                tt.add(file)

    # compile qrc files
    pyqt5ac.main(ioPaths=[[
        '{}/*.qrc'.format(parameters.plugin_path),
        '{}/%%FILENAME%%_rc.py'.format(parameters.plugin_path)
    ]])
    for file in glob('{}/*_rc.py'.format(parameters.plugin_path)):
        with tarfile.open(top_tar_file, mode="a") as tt:
            print('  adding resource: {}'.format(file))
            # https://stackoverflow.com/a/48462950/1548052
            tt.add(file)

    # converting to ZIP
    # why using TAR before? because it provides the prefix and makes things easier
    with zipfile.ZipFile(file=archive_name,
                         mode='w',
                         compression=zipfile.ZIP_DEFLATED) as zf:
        # adding the content of TAR archive
        with tarfile.open(top_tar_file, mode='r:') as tt:
            for m in tt.getmembers():
                if m.isdir():
                    continue
                f = tt.extractfile(m)
                fl = f.read()
                fn = m.name
                zf.writestr(fn, fl)

    print('-------')
    print('files in ZIP archive ({}):'.format(archive_name))
    with zipfile.ZipFile(file=archive_name, mode='r') as zf:
        for f in zf.namelist():
            print(f)
    print('-------')

    # checkout to reset changes
    if initial_stash:
        repo.git.reset('--hard', initial_stash)
        repo.git.reset('HEAD^')
    else:
        repo.git.checkout('--', '.')
Esempio n. 8
0
import pyqt5ac

import PyQt5.uic.pyuic

#https://pypi.org/project/pyqt5ac/
'''
pyqt5ac.main(rccOptions='', uicOptions='--from-imports', force=False, config='',
             ioPaths=[[r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/DistroMap/ui_distromap.ui', r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/DistroMap/ui_distromap.py'],
                      [r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/DistroMap/resources.qrc', r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/DistroMap/resources_rc.py']])


pyqt5ac.main(rccOptions='', uicOptions='--from-imports', force=False, config='',
             ioPaths=[[r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/widget3/widget3_dockwidget_base.ui', r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/widget3/widget3_dockwidget.py'],
                      [r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/widget3/resources.qrc', r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/widget3/resources_rc.py']])
'''
'''
#from .widget3_dockwidget import widget3DockWidget
pyqt5ac.main(rccOptions='', uicOptions='--from-imports', force=False, config='',
             ioPaths=[[r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins/widget3/widget3DockWidget.ui', r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins/widget3/widget3_dockwidget.py'],
                      [r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins/widget3/resources.qrc', r'C:/Users/AG/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins/widget3/resources_rc.py']])
'''

#--- good dock mod----

pyqt5ac.main(
    rccOptions='',
    uicOptions='--from-imports',
    force=False,
    config='',
    ioPaths=
    [[
Esempio n. 9
0
import pyqt5ac
import os

pyqt5ac.main(config=os.path.join(os.path.dirname(__file__), 'config.yml'))
Esempio n. 10
0
from PyQt5.QtCore import *
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import *

# Automatically convert .ui files to .py file
import pyqt5ac

pyqt5ac.main(config='pyqt5ac_config.yml')

from Windows.mainWindow import MainWindow

app = QApplication([])
mw = MainWindow()
mw.show()
app.exec()