From 1bca48c8b60eb4197d57043111af14b0a77d8ee0 Mon Sep 17 00:00:00 2001 From: VB PROGER <97066898+VBPROGER@users.noreply.github.com> Date: Mon, 12 Jun 2023 13:23:17 +0300 Subject: [PATCH 1/6] Added "branch" argument to "pull" --- programpack/__main__.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/programpack/__main__.py b/programpack/__main__.py index 28244ad..167f688 100644 --- a/programpack/__main__.py +++ b/programpack/__main__.py @@ -4,13 +4,20 @@ from tempfile import gettempdir as get_temp_dir import programpack as propack -def pull_from_git(): - execute(f'''cd {get_temp_dir()}; -git clone https://github.com/ProgramPack/programpack.git -b experimental && mv programpack programpack-exp-branch; -cd programpack-exp-branch; +def pull_from_git(branch): + cmd = f'cd {get_temp_dir()};\n' + if branch: + branch = branch.strip() + cmd += f'git clone https://github.com/ProgramPack/programpack.git -b "{branch}" && mv programpack programpack-custom-branch;\n' + else: + cmd += f'git clone https://github.com/ProgramPack/programpack.git -b experimental && mv programpack programpack-exp-branch;\n' + cmd += '''cd programpack-exp-branch; make sinstall && make sclean; cd ..; -true && rm -rf programpack-exp-branch;''') +true && ''' + if branch: cmd += 'rm -rf programpack-custom-branch;' + else: cmd += 'rm -rf programpack-exp-branch;' + execute(cmd) try: argv1 = args[1] except IndexError: argv1 = None @@ -47,8 +54,9 @@ def pull_from_git(): Will attempt to remove the shebang(s) from given file create Create archive from directory name - pull + pull [branch] Update `ProgramPack` to latest version + If `branch` is used, it will pull from branch. version See current version manifest @@ -80,7 +88,7 @@ def pull_from_git(): propack.create_archive(argv2, argv3 or 'create') else: print('usage: create ') -elif argv1 == 'pull': pull_from_git() +elif argv1 == 'pull': pull_from_git(branch = argv2) elif argv1 == 'version': print('ProgramPack - Version {}'.format(propack.__version__)) elif argv1 == 'manifest': if argv2: From ca991c0b84859130816cd27f4be365dbd76a3f23 Mon Sep 17 00:00:00 2001 From: VB PROGER <97066898+VBPROGER@users.noreply.github.com> Date: Mon, 12 Jun 2023 13:27:25 +0300 Subject: [PATCH 2/6] Added `info` command --- programpack/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/programpack/__main__.py b/programpack/__main__.py index 167f688..47d0c16 100644 --- a/programpack/__main__.py +++ b/programpack/__main__.py @@ -2,6 +2,7 @@ from sys import argv as args from os import system as execute from tempfile import gettempdir as get_temp_dir +from json import dumps as dump_to_json import programpack as propack def pull_from_git(branch): @@ -57,6 +58,8 @@ def pull_from_git(branch): pull [branch] Update `ProgramPack` to latest version If `branch` is used, it will pull from branch. + info + See all information about current `ProgramPack` version in JSON version See current version manifest @@ -89,6 +92,7 @@ def pull_from_git(branch): else: print('usage: create ') elif argv1 == 'pull': pull_from_git(branch = argv2) +elif argv1 == 'info': print(str(dump_to_json(propack.__meta__))) elif argv1 == 'version': print('ProgramPack - Version {}'.format(propack.__version__)) elif argv1 == 'manifest': if argv2: From 2b7ce3acc153e7a2f0c862cda28303f9ebea095b Mon Sep 17 00:00:00 2001 From: VB PROGER <97066898+VBPROGER@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:20:58 +0300 Subject: [PATCH 3/6] Added __meta__, added __app_name__ --- programpack/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/programpack/__init__.py b/programpack/__init__.py index 04045ae..17c1a58 100644 --- a/programpack/__init__.py +++ b/programpack/__init__.py @@ -12,10 +12,16 @@ from warnings import warn from requests import get as r_get +__app_name__ = 'ProgramPack' __all__ = [ 'PackedProgram', 'convert_file_to_executable', 'deconvert', 'create_archive' ] __version__ = '0.0.1' +__meta__ = { + 'name': __app_name__, + 'version': __version__, + '__all__': __all__ +} shebang = b'#!/usr/bin/env -S python3 -m programpack run\n' shebang_v = b'#!/usr/bin/env -S python3 -m programpack run --virtual\n' From 5b8559025cca61ef30429bbeb2870682e20d62de Mon Sep 17 00:00:00 2001 From: VB PROGER <97066898+VBPROGER@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:23:06 +0300 Subject: [PATCH 4/6] Fixed "can't cd to ..." bug --- programpack/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/programpack/__main__.py b/programpack/__main__.py index 47d0c16..5569eda 100644 --- a/programpack/__main__.py +++ b/programpack/__main__.py @@ -10,10 +10,11 @@ def pull_from_git(branch): if branch: branch = branch.strip() cmd += f'git clone https://github.com/ProgramPack/programpack.git -b "{branch}" && mv programpack programpack-custom-branch;\n' + cmd += 'cd programpack-custom-branch;\n' else: cmd += f'git clone https://github.com/ProgramPack/programpack.git -b experimental && mv programpack programpack-exp-branch;\n' - cmd += '''cd programpack-exp-branch; -make sinstall && make sclean; + cmd += 'cd programpack-exp-branch;\n' + cmd += '''make sinstall && make sclean; cd ..; true && ''' if branch: cmd += 'rm -rf programpack-custom-branch;' From 55acd2fa423fe109edcdfcbd95bfb59926a1e77a Mon Sep 17 00:00:00 2001 From: VB PROGER <97066898+VBPROGER@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:25:05 +0300 Subject: [PATCH 5/6] Added "manifest" command argument and "file exists?" checking --- programpack/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/programpack/__main__.py b/programpack/__main__.py index 5569eda..e26393c 100644 --- a/programpack/__main__.py +++ b/programpack/__main__.py @@ -97,7 +97,9 @@ def pull_from_git(branch): elif argv1 == 'version': print('ProgramPack - Version {}'.format(propack.__version__)) elif argv1 == 'manifest': if argv2: - print(propack.get_manifest(argv2), end = '') + try: print(propack.get_manifest(argv2), end = '') + except FileNotFoundError: print('error: file doesn\'t exist') + else: print('usage: manifest ') elif argv1 == 'hub': if argv2: if argv2 == 'download': From 0b6be8c7aece1bca3cbb298de456af342ba40b3c Mon Sep 17 00:00:00 2001 From: VB PROGER <97066898+VBPROGER@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:31:41 +0300 Subject: [PATCH 6/6] Added `icon`, `icon update` command(s) --- programpack/__main__.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/programpack/__main__.py b/programpack/__main__.py index e26393c..035692e 100644 --- a/programpack/__main__.py +++ b/programpack/__main__.py @@ -65,6 +65,9 @@ def pull_from_git(branch): See current version manifest Print manifest of file + icon + icon update + Will update file icon manually. hub hub download [output] Will download ProgramPack file by name, domain and author from hub.''' @@ -98,8 +101,17 @@ def pull_from_git(branch): elif argv1 == 'manifest': if argv2: try: print(propack.get_manifest(argv2), end = '') - except FileNotFoundError: print('error: file doesn\'t exist') + except FileNotFoundError: print('error: file {argv2} doesn\'t exist') else: print('usage: manifest ') +elif argv1 == 'icon': + if argv2: + try: + program = propack.PackedProgram(argv2) + program.update_icon(verbose = verbose) + except FileNotFoundError: + print(f'error: file {argv2} doesn\'t exist') + else: + print('usage: icon ') elif argv1 == 'hub': if argv2: if argv2 == 'download': @@ -109,7 +121,7 @@ def pull_from_git(branch): print('usage: hub download [output]') else: print('Unknown hub command. See --help') else: - print('usage: hub <>') + print('usage: hub <...>') else: if len(args) <= 1: print('No args given. See --help.') else: print('Invalid arguments. See --help for more info.')