Skip to content
This repository was archived by the owner on Jan 31, 2019. It is now read-only.

Commit 4810501

Browse files
committed
Merge branch 'freeze-patch'
2 parents 3990a9c + f81d404 commit 4810501

File tree

7 files changed

+93
-20
lines changed

7 files changed

+93
-20
lines changed

Jenkinsfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ stage('Build') {
1717
checkout scm
1818
sh 'git describe --tags > version'
1919
build_ver = readFile 'version'
20+
build_ver = build_ver.replaceAll("\\s","")
2021
println "Building CLI at version ${build_ver}"
2122
}
2223
stage('Build') {
@@ -44,7 +45,11 @@ stage('Build') {
4445
stage('Clone') {
4546
checkout scm
4647
bat 'git describe --tags > version'
47-
build_ver = readFile 'verison'
48+
build_ver = readFile 'version'
49+
build_ver = build_ver.replaceAll("\\s","")
50+
bat 'git describe --tags --abbrev=0 > inst_version'
51+
inst_ver = readFile 'inst_version'
52+
inst_ver = inst_ver.replaceAll("\\s","")
4853
}
4954
stage('Build') {
5055
venv.run 'pip3 install --upgrade -r requirements.txt'
@@ -60,16 +65,20 @@ stage('Build') {
6065
bat 'if exist .\\exe.win del /s /q .\\exe.win'
6166
bat 'if exist .\\exe.win rmdir /s /q .\\exe.win'
6267
bat 'mkdir .\\exe.win'
63-
for(file in unarchive(mapping: ['pros_cli-*-win-32bit.zip': '.'])) {
68+
for(file in unarchive(mapping: ['**pros_cli-*-win-32bit.zip': '.'])) {
6469
file.unzip(file.getParent().child('exe.win'))
6570
}
6671
def advinst = "\"${tool 'Advanced Installer'}\\AdvancedInstaller.com\""
6772
bat """
68-
${advinst} /edit pros-windows.aip /SetVersion ${build_ver}
73+
${advinst} /edit pros-windows.aip /SetVersion ${inst_ver}
6974
${advinst} /edit pros-windows.aip /ResetSync APPDIR\\cli -clearcontent
7075
${advinst} /edit pros-windows.aip /NewSync APPDIR\\cli exe.win -existingfiles delete
7176
${advinst} /build pros-windows.aip
7277
"""
78+
bat """
79+
${advinst} /edit pros-updates.aip /NewUpdate output\\pros-win.exe -name "PROS${inst_ver}" -display_name "PROS ${build_ver}" -url "${env.BUILD_URL}artifact/output/pros-win.exe"
80+
${advinst} /build pros-updates.aip
81+
"""
7382
archiveArtifacts artifacts: 'output/*', fingerprint: true
7483
}
7584
}

proscli/conductor.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# from typing import List
1818

1919

20-
def first_run(ctx: proscli.utils.State, force=False, defaults=False, download=True):
20+
def first_run(ctx: proscli.utils.State, force=False, defaults=False, doDownload=True, reapplyProviders=False):
2121
if len(utils.get_depot_configs(ctx.pros_cfg)) == 0:
2222
click.echo('You don\'t currently have any depots configured.')
2323
if len(utils.get_depot_configs(ctx.pros_cfg)) == 0 or force:
@@ -28,9 +28,11 @@ def first_run(ctx: proscli.utils.State, force=False, defaults=False, download=Tr
2828
configure=False)
2929
click.echo('Added pros-mainline to available depots. '
3030
'Add more depots in the future by running `pros conduct add-depot`\n')
31-
if (defaults or click.confirm('Download the latest kernel?', default=True)) and download:
31+
if (defaults or click.confirm('Download the latest kernel?', default=True)) and doDownload:
3232
click.get_current_context().invoke(download, name='kernel', depot='pros-mainline')
33-
33+
if reapplyProviders:
34+
click.echo('Applying default providers')
35+
ctx.pros_cfg.applyDefaultProviders()
3436

3537
@click.group(cls=AliasGroup)
3638
@default_options
@@ -575,8 +577,10 @@ def upgradelib(cfg, location, library, version, depot):
575577
@click.option('--no-force', is_flag=True, default=True)
576578
@click.option('--use-defaults', is_flag=True, default=False)
577579
@click.option('--no-download', is_flag=True, default=True)
580+
@click.option('--apply-providers', is_flag=True, default=False)
578581
@default_cfg
579-
def first_run_cmd(cfg, no_force, use_defaults, no_download):
580-
first_run(cfg, force=no_force, defaults=use_defaults, download=no_download)
582+
def first_run_cmd(cfg, no_force, use_defaults, no_download, apply_providers):
583+
first_run(cfg, force=no_force, defaults=use_defaults,
584+
doDownload=no_download, reapplyProviders=apply_providers)
581585

582-
import proscli.conductor_management
586+
import proscli.conductor_management

prosconductor/providers/local.py

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import click
2-
import distutils.dir_util
2+
# import distutils.dir_util
33
import fnmatch
44
import os.path
55
from proscli.utils import debug, verbose
@@ -11,6 +11,63 @@
1111
import sys
1212
# from typing import Set, List
1313

14+
def copytree(src, dst, symlinks=False, ignore=None, copy_function=shutil.copy2,
15+
ignore_dangling_symlinks=False):
16+
"""Modified shutil.copytree, but with exist_ok=True
17+
"""
18+
names = os.listdir(src)
19+
if ignore is not None:
20+
ignored_names = ignore(src, names)
21+
else:
22+
ignored_names = set()
23+
24+
os.makedirs(dst, exist_ok=True)
25+
errors = []
26+
for name in names:
27+
if name in ignored_names:
28+
continue
29+
srcname = os.path.join(src, name)
30+
dstname = os.path.join(dst, name)
31+
try:
32+
if os.path.islink(srcname):
33+
linkto = os.readlink(srcname)
34+
if symlinks:
35+
# We can't just leave it to `copy_function` because legacy
36+
# code with a custom `copy_function` may rely on copytree
37+
# doing the right thing.
38+
os.symlink(linkto, dstname)
39+
shutil.copystat(srcname, dstname, follow_symlinks=not symlinks)
40+
else:
41+
# ignore dangling symlink if the flag is on
42+
if not os.path.exists(linkto) and ignore_dangling_symlinks:
43+
continue
44+
# otherwise let the copy occurs. copy2 will raise an error
45+
if os.path.isdir(srcname):
46+
copytree(srcname, dstname, symlinks, ignore,
47+
copy_function)
48+
else:
49+
copy_function(srcname, dstname)
50+
elif os.path.isdir(srcname):
51+
copytree(srcname, dstname, symlinks, ignore, copy_function)
52+
else:
53+
# Will raise a SpecialFileError for unsupported file types
54+
copy_function(srcname, dstname)
55+
# catch the Error from the recursive copytree so that we can
56+
# continue with other files
57+
except shutil.Error as err:
58+
errors.extend(err.args[0])
59+
except OSError as why:
60+
errors.append((srcname, dstname, str(why)))
61+
try:
62+
shutil.copystat(src, dst)
63+
except OSError as why:
64+
# Copying file access times may fail on Windows
65+
if getattr(why, 'winerror', None) is None:
66+
errors.append((src, dst, str(why)))
67+
if errors:
68+
raise Error(errors)
69+
return dst
70+
1471

1572
def get_local_templates(pros_cfg=None, filters=[],
1673
template_types=None):
@@ -57,7 +114,7 @@ def create_project(identifier, dest, pros_cli=None):
57114
click.get_current_context().abort()
58115
sys.exit()
59116
config = TemplateConfig(file=filename)
60-
distutils.dir_util.copy_tree(config.directory, dest)
117+
copytree(config.directory, dest)
61118
for root, dirs, files in os.walk(dest):
62119
for d in dirs:
63120
if any([fnmatch.fnmatch(d, p) for p in config.template_ignore]):
@@ -124,7 +181,7 @@ def install_lib(identifier, dest, pros_cli):
124181
sys.exit()
125182
proj_config = prosconfig.ProjectConfig(dest)
126183
config = TemplateConfig(file=filename)
127-
distutils.dir_util.copy_tree(config.directory, dest)
184+
copytree(config.directory, dest)
128185
for root, dirs, files in os.walk(dest):
129186
for d in dirs:
130187
if any([fnmatch.fnmatch(d, p) for p in config.template_ignore]):

prosconductor/providers/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ def get_all_provider_types(pros_cfg=None):
1414
pros_cfg = CliConfig()
1515

1616
for provider_file in pros_cfg.providers:
17-
spec = importlib.util.spec_from_file_location('prosconductor.providers.{}'.format(os.path.basename(provider_file).split('.')[0]), provider_file)
18-
spec.loader.load_module()
17+
if os.path.isfile(provider_file):
18+
spec = importlib.util.spec_from_file_location('prosconductor.providers.{}'.format(os.path.basename(provider_file).split('.')[0]), provider_file)
19+
spec.loader.load_module()
1920

2021
return {x.registrar: x for x in DepotProvider.__subclasses__()}
2122

prosconfig/cliconfig.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ def __init__(self, file=None, ctx=None):
1010
if not file:
1111
file = os.path.join(click.get_app_dir('PROS'), 'cli.pros')
1212
self.default_libraries = [] # type: list(str)
13+
self.providers = []
14+
self.applyDefaultProviders()
15+
super(CliConfig, self).__init__(file, ctx=ctx)
16+
17+
def applyDefaultProviders(self):
1318
if os.path.isfile(prosconductor.providers.githubreleases.__file__):
14-
self.providers = [prosconductor.providers.githubreleases.__file__]
19+
self.providers.append(prosconductor.providers.githubreleases.__file__)
1520
elif hasattr(sys, 'frozen'):
16-
self.providers = [os.path.join(os.path.dirname(sys.executable), 'githubreleases.pyc')]
17-
else:
18-
self.providers = []
19-
super(CliConfig, self).__init__(file, ctx=ctx)
21+
self.providers.append(os.path.join(os.path.dirname(sys.executable), 'githubreleases.pyc'))

prosflasher/bootloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def compute_address_commandable(address):
4646
def prepare_bootloader(port):
4747
click.echo('Preparing bootloader...', nl=False)
4848
prosflasher.upload.configure_port(port, serial.PARITY_EVEN)
49-
port.write([0x7f])
5049
port.flush()
50+
port.write([0x7f])
5151
response = port.read(1)
5252
debug_response(0x07f, response)
5353
if response is None or len(response) != 1 or response[0] != ACK:

version

2 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)