1
0

script è linted. Corretto codice in check su build.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Emiliano Vavassori 2023-01-07 02:03:31 +01:00
parent 03620cf013
commit 0a3f475fa6
2 changed files with 60 additions and 31 deletions

View File

@ -149,10 +149,13 @@ class Build(loaih.RemoteBuild):
# Remote storage. I have to query a remote site to know if it # Remote storage. I have to query a remote site to know if it
# was already built. # was already built.
name = self.appimagefilename[arch] name = self.appimagefilename[arch]
if len(self.relative_path) > 0: if len(self.relative_path) == 0:
path_arr = self.relative_path.insert(0, self.storage_path)
else:
path_arr = [ self.storage_path, '' ] path_arr = [ self.storage_path, '' ]
elif len(self.relative_path) == 1:
path_arr = [ self.storage_path, self.relative_path[0], '' ]
else:
path_arr = self.relative_path.insert(0, self.storage_path)
path = str.join('/', path_arr) path = str.join('/', path_arr)
print(f"DEBUG - Name: {name}, URL: {path}") print(f"DEBUG - Name: {name}, URL: {path}")
matching = [] matching = []

View File

@ -1,67 +1,85 @@
#!/usr/bin/env python #!/usr/bin/env python
# encoding: utf-8 # encoding: utf-8
"""Helps with command line commands."""
import json
import click import click
import yaml import yaml
import loaih, loaih.build import loaih
import re, sys, json import loaih.build
@click.group() @click.group()
def cli(): def cli():
pass """Helps with command line commands."""
@cli.command() @cli.command()
@click.option('-j', '--json', 'jsonout', default=False, is_flag=True, help="Output format in json.") @click.option('-j', '--json', 'jsonout', default=False, is_flag=True,
help="Output format in json.")
@click.argument('query') @click.argument('query')
def getversion(query, jsonout): def getversion(query, jsonout):
b = [] """Get the numeral version from a named version."""
batch = []
queries = [] queries = []
if ',' in query: if ',' in query:
queries.extend(query.split(',')) queries.extend(query.split(','))
else: else:
queries.append(query) queries.append(query)
for q in queries: for singlequery in queries:
b.extend(loaih.Base.collectedbuilds(q)) batch.extend(loaih.Base.collectedbuilds(singlequery))
if len(b) > 0: if len(batch) > 0:
if jsonout: if jsonout:
click.echo(json.dumps([x.todict() for x in b])) click.echo(json.dumps([x.todict() for x in batch]))
else: else:
for v in b: for value in batch:
click.echo(v) click.echo(value)
@cli.command() @cli.command()
@click.option('-a', '--arch', 'arch', type=click.Choice(['x86', 'x86_64', 'all'], case_sensitive=False), default='all', help="Build the AppImage for a specific architecture. If there is no specific options, the process will build for both architectures (if available). Default: all") @click.option('-a', '--arch', 'arch', default='all',
@click.option('-c/-C', '--check/--no-check', 'check', default=True, help="Check in the final storage if the queried version is existent. Default: check") type=click.Choice(['x86', 'x86_64', 'all'], case_sensitive=False),
@click.option('-d', '--download-path', 'download_path', default = '/var/tmp/downloads', type=str, help="Path to the download folder. Default: /var/tmp/downloads") help="Build the AppImage for a specific architecture. If there is no specific options, the process will build for both architectures (if available). Default: all")
@click.option('-l', '--language', 'language', default = 'basic', type=str, help="Languages to be included. Options: basic, standard, full, a language string (e.g. 'it') or a list of languages comma separated (e.g.: 'en-US,en-GB,it'). Default: basic") @click.option('-c/-C', '--check/--no-check', 'check', default=True,
@click.option('-o/-O', '--offline-help/--no-offline-help', 'offline', default = False, help="Include or not the offline help for the chosen languages. Default: no offline help") help="Check in the final storage if the queried version is existent. Default: check")
@click.option('-p/-P', '--portable/--no-portable', 'portable', default = False, help="Create a portable version of the AppImage or not. Default: no portable") @click.option('-d', '--download-path', 'download_path',
@click.option('-r', '--repo-path', 'repo_path', default = '/mnt/appimage', type=str, help="Path to the final storage of the AppImage. Default: /mnt/appimage") default = '/var/tmp/downloads', type=str,
@click.option('-s/-S', '--sign/--no-sign', 'sign', default=True, help="Wether to sign the build. Default: sign") help="Path to the download folder. Default: /var/tmp/downloads")
@click.option('-u/-U', '--updatable/--no-updatable', 'updatable', default = True, help="Create an updatable version of the AppImage or not. Default: updatable") @click.option('-l', '--language', 'language', default = 'basic', type=str,
help="Languages to be included. Options: basic, standard, full, a language string (e.g. 'it') or a list of languages comma separated (e.g.: 'en-US,en-GB,it'). Default: basic")
@click.option('-o/-O', '--offline-help/--no-offline-help', 'offline', default = False,
help="Include or not the offline help for the chosen languages. Default: no offline help")
@click.option('-p/-P', '--portable/--no-portable', 'portable', default = False,
help="Create a portable version of the AppImage or not. Default: no portable")
@click.option('-r', '--repo-path', 'repo_path', default = '/mnt/appimage',
type=str, help="Path to the final storage of the AppImage. Default: /mnt/appimage")
@click.option('-s/-S', '--sign/--no-sign', 'sign', default=True,
help="Wether to sign the build. Default: sign")
@click.option('-u/-U', '--updatable/--no-updatable', 'updatable', default = True,
help="Create an updatable version of the AppImage or not. Default: updatable")
@click.argument('query') @click.argument('query')
def build(arch, language, offline, portable, updatable, download_path, repo_path, check, sign, query): def build(arch, language, offline, portable, updatable, download_path, repo_path, check, sign, query):
"""Builds an Appimage with the provided options."""
# Parsing options # Parsing options
arches = [] arches = []
if arch.lower() == 'all': if arch.lower() == 'all':
# We need to build it twice. # We need to build it twice.
arches = [ u'x86', u'x86_64' ] arches = [ 'x86', 'x86_64' ]
else: else:
arches = [ arch.lower() ] arches = [ arch.lower() ]
if query.endswith('.yml') or query.endswith('.yaml'): if query.endswith('.yml') or query.endswith('.yaml'):
# This is a buildfile. So we have to load the file and pass the build options ourselves. # This is a buildfile. So we have to load the file and pass the build options ourselves.
config = {} config = {}
with open(query, 'r') as file: with open(query, 'r', encoding= 'utf-8') as file:
config = yaml.safe_load(file) config = yaml.safe_load(file)
# With the config file, we ignore all the command line options and set # With the config file, we ignore all the command line options and set
# generic default. # generic default.
for build in config['builds']: for cbuild in config['builds']:
# Loop a run for each build. # Loop a run for each build.
collection = loaih.build.Collection(build['query'], arches) collection = loaih.build.Collection(cbuild['query'], arches)
for obj in collection: for obj in collection:
# Configuration phase # Configuration phase
@ -69,12 +87,20 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
obj.offline_help = build['offline_help'] obj.offline_help = build['offline_help']
obj.portable = build['portable'] obj.portable = build['portable']
obj.updatable = True obj.updatable = True
obj.storage_path = config['data']['repo'] if 'repo' in config['data'] and config['data']['repo'] else '/srv/http/appimage.sys42.eu' obj.storage_path = "/srv/http/appimage.sys42.eu"
obj.download_path = config['data']['download'] if 'download' in config['data'] and config['data']['download'] else '/var/tmp/downloads' if 'repo' in config['data'] and config['data']['repo']:
obj.storage_path = config['data']['repo']
obj.download_path = "/var/tmp/downloads"
if 'download' in config['data'] and config['data']['download']:
obj.download_path = config['data']['download']
if 'http' in obj.storage_path: if 'http' in obj.storage_path:
obj.remoterepo = True obj.remoterepo = True
obj.remote_host = config['data']['remote_host'] if 'remote_host' in config['data'] and config['data']['remote_host'] else 'ciccio.libreitalia.org' obj.remote_host = "ciccio.libreitalia.org"
obj.remote_path = config['data']['remote_path'] if 'remote_path' in config['data'] and config['data']['remote_path'] else '/var/lib/nethserver/vhost/appimages' if 'remote_host' in config['data'] and config['data']['remote_host']:
obj.remote_host = config['data']['remote_host']
obj.remote_path = "/var/lib/nethserver/vhost/appimages"
if 'remote_path' in config['data'] and config['data']['remote_path']:
obj.remote_path = config['data']['remote_path']
if 'sign' in config['data'] and config['data']['sign']: if 'sign' in config['data'] and config['data']['sign']:
obj.sign = True obj.sign = True