Skip to content
Snippets Groups Projects
Select Git revision
  • f18dd4ee78cd9049d73a8e50041021e06e6e27bd
  • master default protected
  • dev
  • appimage
  • fix_gitlab
  • fixappveyor
  • gitlab
  • fix_ci
  • fix_dbus_error
  • fix_ci_osx
  • sakia020
  • fix_travis#1105
  • feature/backend
  • check_uniq_node_by_endpoints
  • qt5.7
  • feature/agent_architecture
  • translations
  • pyqt5.6
  • qtwebengine
  • pyinstaller
  • landscape
  • 0.53.2
  • 0.53.1
  • 0.53.0
  • 0.52.0
  • 0.51.1
  • 0.51.0
  • 0.50.5
  • 0.50.4
  • 0.50.3
  • 0.50.2
  • 0.50.1
  • 0.50.0
  • 0.33.0rc7
  • 0.33.0rc6
  • 0.33.0rc5
  • 0.33.0rc4
  • 0.33.0rc3
  • 0.33.0rc2
  • 0.33.0rc1
  • 0.32.10post1
41 results

gen_resources.py

Blame
  • gen_resources.py 1.61 KiB
    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    import sys, os, multiprocessing, subprocess
    
    resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'res'))
    gen_ui = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src', 'cutecoin', 'gen_resources'))
    gen_resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))
    
    def convert_ui(args, **kwargs):
        subprocess.call(args, **kwargs)
    
    def build_resources():
        try:
            to_process = []
            for root, dirs, files in os.walk(resources):
                for f in files:
                    if f.endswith('.ui'):
                        source = os.path.join(root, f)
                        dest = os.path.join(gen_ui, os.path.splitext(os.path.basename(source))[0]+'_uic.py')
                        exe = 'pyuic5'
                    elif f.endswith('.qrc'):
                        source = os.path.join(root, f)
                        dest = os.path.join(gen_resources, os.path.splitext(os.path.basename(source))[0]+'_rc.py')
                        exe = 'pyrcc5'
                    else:
                        continue
                    print(source + " >> " + dest)
                    to_process.append([exe, '-o', dest, source])
    
            if sys.platform.startswith('win'):
                # doing this in parallel on windows will crash your computer
                [convert_ui(args, shell=True) for args in to_process]
            else:
                pool = multiprocessing.Pool()
                pool.map(convert_ui, to_process)
        except EnvironmentError:
            print("""\
    Warning: PyQt5 development utilities (pyuic5 and pyrcc5) not found
    Unable to install praxes' graphical user interface
    """)
    
    build_resources()