Beispiel #1
0
    def run_project_(self):

        # config files #
        project = files.readall('/proc/info/psel')
        user = files.readall('/proc/info/su')
        if not user == 'root':
            path = f'/desk/{user}/Projects/{project}'
        else:
            path = f'/root/Projects/{project}'

        config = path + "/.pypersia"

        rand = str(random.randint(1000, 9999))

        compile = files.readall(f'{path}/packs/{project}/control/compile')
        compile = compile.replace(f'{project}.pyc', f'{project}_{rand}.pyc')
        files.write(f'{path}/packs/{project}/control/compile', compile)

        if control.read_record('type', config) == 'gui' or control.read_record(
                'type', config) == 'web':
            control.write_record(
                'exec', f'{project}_{rand}',
                f'{path}/packs/{project}/data/usr/share/applications/{project}.desk'
            )
            files.cut(
                f'{path}/packs/{project}/data/usr/share/applications/{project}.desk',
                f'{path}/packs/{project}/data/usr/share/applications/{project}_{rand}.desk'
            )

            System(f'paye pak {path}/packs/{project}')
            System(f'paye upak {path}/packs/{project}.pa')

            self.Env.RunApp(f'{project}_{rand}', [None])

            files.cut(
                f'{path}/packs/{project}/data/usr/share/applications/{project}_{rand}.desk',
                f'{path}/packs/{project}/data/usr/share/applications/{project}.desk'
            )
        else:
            System(f'paye pak {path}/packs/{project}')
            System(f'paye upak {path}/packs/{project}.pa')

            self.Env.RunApp('commento',
                            [f"{project}_{rand}", 'PyPersia Console'])

        if files.isfile(f'{path}/packs/{project}.pa'):
            files.remove(f'{path}/packs/{project}.pa')
        System(f'paye rm {project}')

        compile = files.readall(f'{path}/packs/{project}/control/compile')
        compile = compile.replace(f'{project}_{rand}.pyc', f'{project}.pyc')
        files.write(f'{path}/packs/{project}/control/compile', compile)
Beispiel #2
0
    def project_create_web(self, projectname):
        su = files.readall('/proc/info/su')

        if not su == 'root':
            System(f"paye crt web /desk/{su}/Projects/{projectname}")
            commands.cd([f'/desk/{su}/Projects/{projectname}'])
        else:
            System(f"paye crt web /root/Projects/{projectname}")
            commands.cd([f'/root/Projects/{projectname}'])

        commands.mv(['packs/app', f'packs/{projectname}'])
        commands.mv([
            f'packs/{projectname}/data/usr/share/docs/hello',
            f'packs/{projectname}/data/usr/share/docs/{projectname}'
        ])
        commands.mv([
            f'packs/{projectname}/code/hello.py',
            f'packs/{projectname}/code/{projectname}.py'
        ])
        commands.mv([
            f'packs/{projectname}/data/usr/share/applications/hello.desk',
            f'packs/{projectname}/data/usr/share/applications/{projectname}.desk'
        ])
        files.write(
            f'packs/{projectname}/control/manifest',
            f'name: {projectname}\ncopyright: (c) 2020 Your name\nlicense: Your license\nunpack: /\nbuild: year-month-day\nversion: 0.0.1\ndescription: Your application description\ncompile: Yes'
        )
        files.write(f'packs/{projectname}/control/compile',
                    f'{projectname}.py:usr/app/{projectname}.pyc')
        files.write(
            f'packs/{projectname}/control/list',
            f'/usr/app/{projectname}.pyc\n/usr/share/docs/{projectname}')
        files.write(
            f'packs/{projectname}/data/usr/share/applications/{projectname}.desk',
            f'name[en]: {projectname}\nlogo: @icon/runner\nexec: {projectname}'
        )

        files.write('/proc/info/psel', projectname)
        files.create(".pypersia")

        control.write_record('name', projectname, ".pypersia")
        control.write_record('type', 'web', ".pypersia")
        control.write_record('lang', 'python', '.pypersia')
        app.switch('persia')
        self.Env.RunApp('persia', [projectname])
        app.switch('persia')
Beispiel #3
0
    def rem_x(self, name):
        if not files.isfile(f'/app/packages/{name}.manifest'):
            self.Env.RunApp('text', [
                'Package was not installed',
                f'Cannot remove {name} package; beacause this package was not installed.'
            ])

        else:
            System(f'paye rm {name}')

            self.Widget.close()
            self.Env.RunApp('paye', [None])

            self.Env.RunApp('text', [
                'Successfully removed', f'{name} package successfully removed.'
            ])
Beispiel #4
0
    def generate_pa_(self):
        self.project = files.readall('/proc/info/psel')
        self.user = files.readall('/proc/info/su')
        if not self.user == 'root':
            self.path = f'/desk/{self.user}/Projects/{self.project}'
        else:
            self.path = f'/root/Projects/{self.project}'

        self.config = self.path + "/.pypersia"

        self.projectname = control.read_record('name', self.config)

        System(f'paye pak {self.path}/packs/{self.projectname}')
        commands.mv([
            f'{self.path}/packs/{self.projectname}.pa',
            f'{self.path}/{self.projectname}.pa'
        ])

        self.x.genpa(self.projectname)
Beispiel #5
0
    def down_x(self, name):
        if not files.isfile(f'/app/mirrors/{name}'):
            self.Env.RunApp('text', [
                'Mirror not found',
                f'Cannot download package with {name} name; because mirror of this package not found.'
            ])
        else:
            try:
                System(f'paye get {name}')

                self.Widget.Close()
                self.Env.RunApp('paye', [None])
                self.Env.RunApp('text', [
                    'Successfully downloaded',
                    f'{name} package successfully downloaded in current path.'
                ])
            except:
                self.Env.RunApp('text', [
                    'Connot download',
                    f'Cannot download package with {name} name; there are some errors in connection or etc.'
                ])
Beispiel #6
0
    def inst_x(self, name):
        if not files.isfile(f'/app/mirrors/{name}'):
            self.Env.RunApp('text', [
                'Mirror not found',
                f'Cannot install package with {name} name; because mirror of this package not found.'
            ])
        else:
            try:
                System(f'paye in {name}')

                self.Widget.Close()
                self.Env.RunApp('paye', [None])
                self.Env.RunApp('text', [
                    'Successfully installed',
                    f'{name} package successfully installed.'
                ])
            except:
                self.Env.RunApp('text', [
                    'Connot install',
                    f'Cannot install package with {name} name; there are some errors in connection or etc.'
                ])
Beispiel #7
0
 def Game(self):
     System('/usr/games/squares')  # Run CatBall Game
Beispiel #8
0
    def install_(self):
        if not files.isfile(f"{self.path}/{self.projectname}.pa"):
            self.generate_pa_()

        if not files.isdir(f"{self.path}/{self.projectname}.pa"):
            System(f'paye upak {self.path}/{self.projectname}.pa')
Beispiel #9
0
 def xuni_(self, yes):
     if yes:
         System(f"paye rm {self.External[0]}")
         self.Env.Close()
         self.Backend.RunApp('paye', [None])