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

Commit

Permalink
Merge branch 'freeze-patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
edjubuh committed Feb 8, 2017
2 parents 3990a9c + f81d404 commit 4810501
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 20 deletions.
15 changes: 12 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ stage('Build') {
checkout scm
sh 'git describe --tags > version'
build_ver = readFile 'version'
build_ver = build_ver.replaceAll("\\s","")
println "Building CLI at version ${build_ver}"
}
stage('Build') {
Expand Down Expand Up @@ -44,7 +45,11 @@ stage('Build') {
stage('Clone') {
checkout scm
bat 'git describe --tags > version'
build_ver = readFile 'verison'
build_ver = readFile 'version'
build_ver = build_ver.replaceAll("\\s","")
bat 'git describe --tags --abbrev=0 > inst_version'
inst_ver = readFile 'inst_version'
inst_ver = inst_ver.replaceAll("\\s","")
}
stage('Build') {
venv.run 'pip3 install --upgrade -r requirements.txt'
Expand All @@ -60,16 +65,20 @@ stage('Build') {
bat 'if exist .\\exe.win del /s /q .\\exe.win'
bat 'if exist .\\exe.win rmdir /s /q .\\exe.win'
bat 'mkdir .\\exe.win'
for(file in unarchive(mapping: ['pros_cli-*-win-32bit.zip': '.'])) {
for(file in unarchive(mapping: ['**pros_cli-*-win-32bit.zip': '.'])) {
file.unzip(file.getParent().child('exe.win'))
}
def advinst = "\"${tool 'Advanced Installer'}\\AdvancedInstaller.com\""
bat """
${advinst} /edit pros-windows.aip /SetVersion ${build_ver}
${advinst} /edit pros-windows.aip /SetVersion ${inst_ver}
${advinst} /edit pros-windows.aip /ResetSync APPDIR\\cli -clearcontent
${advinst} /edit pros-windows.aip /NewSync APPDIR\\cli exe.win -existingfiles delete
${advinst} /build pros-windows.aip
"""
bat """
${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"
${advinst} /build pros-updates.aip
"""
archiveArtifacts artifacts: 'output/*', fingerprint: true
}
}
Expand Down
16 changes: 10 additions & 6 deletions proscli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# from typing import List


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

if reapplyProviders:
click.echo('Applying default providers')
ctx.pros_cfg.applyDefaultProviders()

@click.group(cls=AliasGroup)
@default_options
Expand Down Expand Up @@ -575,8 +577,10 @@ def upgradelib(cfg, location, library, version, depot):
@click.option('--no-force', is_flag=True, default=True)
@click.option('--use-defaults', is_flag=True, default=False)
@click.option('--no-download', is_flag=True, default=True)
@click.option('--apply-providers', is_flag=True, default=False)
@default_cfg
def first_run_cmd(cfg, no_force, use_defaults, no_download):
first_run(cfg, force=no_force, defaults=use_defaults, download=no_download)
def first_run_cmd(cfg, no_force, use_defaults, no_download, apply_providers):
first_run(cfg, force=no_force, defaults=use_defaults,
doDownload=no_download, reapplyProviders=apply_providers)

import proscli.conductor_management
import proscli.conductor_management
63 changes: 60 additions & 3 deletions prosconductor/providers/local.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import click
import distutils.dir_util
# import distutils.dir_util
import fnmatch
import os.path
from proscli.utils import debug, verbose
Expand All @@ -11,6 +11,63 @@
import sys
# from typing import Set, List

def copytree(src, dst, symlinks=False, ignore=None, copy_function=shutil.copy2,
ignore_dangling_symlinks=False):
"""Modified shutil.copytree, but with exist_ok=True
"""
names = os.listdir(src)
if ignore is not None:
ignored_names = ignore(src, names)
else:
ignored_names = set()

os.makedirs(dst, exist_ok=True)
errors = []
for name in names:
if name in ignored_names:
continue
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
try:
if os.path.islink(srcname):
linkto = os.readlink(srcname)
if symlinks:
# We can't just leave it to `copy_function` because legacy
# code with a custom `copy_function` may rely on copytree
# doing the right thing.
os.symlink(linkto, dstname)
shutil.copystat(srcname, dstname, follow_symlinks=not symlinks)
else:
# ignore dangling symlink if the flag is on
if not os.path.exists(linkto) and ignore_dangling_symlinks:
continue
# otherwise let the copy occurs. copy2 will raise an error
if os.path.isdir(srcname):
copytree(srcname, dstname, symlinks, ignore,
copy_function)
else:
copy_function(srcname, dstname)
elif os.path.isdir(srcname):
copytree(srcname, dstname, symlinks, ignore, copy_function)
else:
# Will raise a SpecialFileError for unsupported file types
copy_function(srcname, dstname)
# catch the Error from the recursive copytree so that we can
# continue with other files
except shutil.Error as err:
errors.extend(err.args[0])
except OSError as why:
errors.append((srcname, dstname, str(why)))
try:
shutil.copystat(src, dst)
except OSError as why:
# Copying file access times may fail on Windows
if getattr(why, 'winerror', None) is None:
errors.append((src, dst, str(why)))
if errors:
raise Error(errors)
return dst


def get_local_templates(pros_cfg=None, filters=[],
template_types=None):
Expand Down Expand Up @@ -57,7 +114,7 @@ def create_project(identifier, dest, pros_cli=None):
click.get_current_context().abort()
sys.exit()
config = TemplateConfig(file=filename)
distutils.dir_util.copy_tree(config.directory, dest)
copytree(config.directory, dest)
for root, dirs, files in os.walk(dest):
for d in dirs:
if any([fnmatch.fnmatch(d, p) for p in config.template_ignore]):
Expand Down Expand Up @@ -124,7 +181,7 @@ def install_lib(identifier, dest, pros_cli):
sys.exit()
proj_config = prosconfig.ProjectConfig(dest)
config = TemplateConfig(file=filename)
distutils.dir_util.copy_tree(config.directory, dest)
copytree(config.directory, dest)
for root, dirs, files in os.walk(dest):
for d in dirs:
if any([fnmatch.fnmatch(d, p) for p in config.template_ignore]):
Expand Down
5 changes: 3 additions & 2 deletions prosconductor/providers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def get_all_provider_types(pros_cfg=None):
pros_cfg = CliConfig()

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

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

Expand Down
12 changes: 7 additions & 5 deletions prosconfig/cliconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ def __init__(self, file=None, ctx=None):
if not file:
file = os.path.join(click.get_app_dir('PROS'), 'cli.pros')
self.default_libraries = [] # type: list(str)
self.providers = []
self.applyDefaultProviders()
super(CliConfig, self).__init__(file, ctx=ctx)

def applyDefaultProviders(self):
if os.path.isfile(prosconductor.providers.githubreleases.__file__):
self.providers = [prosconductor.providers.githubreleases.__file__]
self.providers.append(prosconductor.providers.githubreleases.__file__)
elif hasattr(sys, 'frozen'):
self.providers = [os.path.join(os.path.dirname(sys.executable), 'githubreleases.pyc')]
else:
self.providers = []
super(CliConfig, self).__init__(file, ctx=ctx)
self.providers.append(os.path.join(os.path.dirname(sys.executable), 'githubreleases.pyc'))
2 changes: 1 addition & 1 deletion prosflasher/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def compute_address_commandable(address):
def prepare_bootloader(port):
click.echo('Preparing bootloader...', nl=False)
prosflasher.upload.configure_port(port, serial.PARITY_EVEN)
port.write([0x7f])
port.flush()
port.write([0x7f])
response = port.read(1)
debug_response(0x07f, response)
if response is None or len(response) != 1 or response[0] != ACK:
Expand Down
Binary file modified version
Binary file not shown.

0 comments on commit 4810501

Please sign in to comment.