예제 #1
0
    files.write('/tmp/width', str(width))
    files.write('/tmp/height', str(height))

    if not desktop == None:
        w = importlib.import_module(desktop).Backend()
    else:
        colors.show('gui', 'fail-start', '')
        colors.show('kernel', 'stop', '')

    sys.exit(application.exec_())

## @core/gui-splash ##

if argv[0] == "gui-splash":
    desktop = control.read_record('desktop', '/etc/gui')
    control.write_record('params', 'splash', '/etc/gui')

    from PyQt5.QtCore import *
    from PyQt5.QtWidgets import *
    from PyQt5.QtWebEngineWidgets import *

    ## Main entry ##
    application = QApplication(sys.argv)
    app.start('desktop')
    ## https://www.cdog.pythonlibrary.org/2015/08/18/getting-your-screen-resolution-with-python/ Get screen model ##
    screen_resolution = application.desktop().screenGeometry()
    width, height = screen_resolution.width(), screen_resolution.height()

    files.write('/tmp/width', str(width))
    files.write('/tmp/height', str(height))
예제 #2
0
    def run_(self):
        control = Control()
        file = files.readall('/proc/info/fsel')

        ## Run it ##
        if file.endswith(".c") or file.endswith('.cpp') or file.endswith(
                '.cxx') or file.endswith('.c++'):
            filename = file
            execname = file.replace('.cpp', '').replace('.cxx', '').replace(
                '.c++', '').replace('.c', '')
            files.write(
                '/tmp/exec.sa', f'''
say Compiling {filename} ...
cc {filename}
echo done
echo Running {execname} ...
echo
{execname}
echo
echo Finish runing process with exit 0 ...
rm /tmp/exec.sa
rm {execname}
pause
                        ''')
            self.Env.RunApp('commento', [None])
            app.switch('persia')
            files.remove(execname)

        elif file.endswith('.py'):
            # check graphical PyQt5 #
            if files.readall(file).__contains__(
                    'from PyQt5') and files.readall(file).__contains__(
                        'MainApp'):
                rand = str(random.randint(1000, 9999))
                files.create(f'/usr/share/applications/debug_{rand}.desk')
                control.write_record(
                    'name[en]', 'Debug App',
                    f'/usr/share/applications/debug_{rand}.desk')
                control.write_record(
                    'name[fa]', 'برنامه تستی',
                    f'/usr/share/applications/debug_{rand}.desk')
                control.write_record(
                    'logo', '@icon/runner',
                    f'/usr/share/applications/debug_{rand}.desk')
                control.write_record(
                    'exec', f"debug_{rand}",
                    f'/usr/share/applications/debug_{rand}.desk')
                app.switch('persia')
                py_compile.compile(files.input(file),
                                   files.input(f'/usr/app/debug_{rand}.pyc'))
                self.Env.RunApp(f'debug_{rand}', [None])
                app.switch('persia')
                files.remove(f'/usr/share/applications/debug_{rand}.desk')
                files.remove(f'/usr/app/debug_{rand}.pyc')
            else:
                execname = file.replace('.py', '')
                files.write(
                    '/tmp/exec.sa', f'''
echo Running {execname} ...
echo
{execname}
echo
echo Finish runing process with exit 0 ...
rm /tmp/exec.sa
pause
                                                        ''')
                self.Env.RunApp('commento', [None])
                app.switch('persia')

        elif file.endswith('.sa'):
            execname = file.replace('.sa', '')
            files.write(
                '/tmp/exec.sa', f'''
echo Running {execname} ...
echo
{execname}
echo
echo Finish runing process with exit 0 ...
rm /tmp/exec.sa
pause
                                        ''')
            self.Env.RunApp('commento', [None])
            app.switch('persia')
        else:
            app.switch('persia')
            self.Env.RunApp('text',
                            [res.get('@string/spc'),
                             res.get('@string/spcm')])
            app.switch('persia')
예제 #3
0
    def run_(self):
        control = Control()
        file = files.readall('/proc/info/fsel')

        ## Run it ##
        if file.endswith(".c") or file.endswith('.cpp') or file.endswith(
                '.cxx') or file.endswith('.c++'):
            try:
                commands.cc([file])
            except:
                self.Env.RunApp('text', [
                    'Compile error',
                    'There is some problem with C/++ Compiler.'
                ])

            self.Env.RunApp('commento', [
                file.replace('.cpp', '').replace('.cxx', '').replace(
                    '.c++', '').replace('.c', ''), 'PyPersia Console'
            ])
            files.remove(
                file.replace('.c',
                             '').replace('.cpp',
                                         '').replace('.cxx',
                                                     '').replace('.c++', ''))
        elif file.endswith('.py'):
            # check graphical PyQt5 #
            if files.readall(file).__contains__(
                    'from PyQt5') and files.readall(file).__contains__(
                        'MainApp'):
                rand = str(random.randint(1000, 9999))
                files.create(f'/usr/share/applications/debug_{rand}.desk')
                control.write_record(
                    'name[en]', 'Debug App',
                    f'/usr/share/applications/debug_{rand}.desk')
                control.write_record(
                    'name[fa]', 'برنامه تستی',
                    f'/usr/share/applications/debug_{rand}.desk')
                control.write_record(
                    'logo', '@icon/runner',
                    f'/usr/share/applications/debug_{rand}.desk')
                control.write_record(
                    'exec', f"debug_{rand}",
                    f'/usr/share/applications/debug_{rand}.desk')
                py_compile.compile(files.input(file),
                                   files.input(f'/usr/app/debug_{rand}.pyc'))
                self.Env.RunApp(f'debug_{rand}', [None])
                files.remove(f'/usr/share/applications/debug_{rand}.desk')
                files.remove(f'/usr/app/debug_{rand}.pyc')
            else:
                commands.cp([file, '/usr/app/' + files.filename(file)])
                self.Env.RunApp('commento', [
                    files.filename(file.replace('.py', '')), 'PyPersia Console'
                ])
                commands.rm(['/usr/app/' + files.filename(file)])
        elif file.endswith('.sa'):
            self.Env.RunApp('commento',
                            [file.replace('.sa', ''), 'PyPersia Console'])
        else:
            self.Env.RunApp('text', [
                'Cannot Support',
                'PyPersia cannot support this language or syntax.'
            ])