[Bf-blender-cvs] [705695bf4d9] soc-2017-package_manager: pep8-ify bl_operators/package.py
gandalf3
noreply at git.blender.org
Tue Aug 29 11:46:03 CEST 2017
Commit: 705695bf4d98c3b4ca86d4a95da48d9f7d70a8e4
Author: gandalf3
Date: Mon Aug 28 22:46:30 2017 -0700
Branches: soc-2017-package_manager
https://developer.blender.org/rB705695bf4d98c3b4ca86d4a95da48d9f7d70a8e4
pep8-ify bl_operators/package.py
===================================================================
M release/scripts/startup/bl_operators/package.py
===================================================================
diff --git a/release/scripts/startup/bl_operators/package.py b/release/scripts/startup/bl_operators/package.py
index 9045ba05fed..d6e9e7891cd 100644
--- a/release/scripts/startup/bl_operators/package.py
+++ b/release/scripts/startup/bl_operators/package.py
@@ -36,8 +36,10 @@ else:
log = logging.getLogger(__name__ + '.SubprocMixin')
_state = 'INITIALIZING'
- _abort_timeout = 0 # time at which we stop waiting for an abort response and just terminate the process
- _abort_wait = 10 # how long to wait (in seconds) to forcibly terminate subprocess after quit
+ # time at which we stop waiting for an abort response and just terminate the process
+ _abort_timeout = 0
+ # how long to wait (in seconds) to forcibly terminate subprocess after quit
+ _abort_wait = 10
# Mapping from message type (see bpkg.messages) to handler function.
# Should be constructed before modal() gets called.
@@ -75,8 +77,10 @@ else:
return {'PASS_THROUGH'}
if self._state == 'ABORTING' and time.time() > self._abort_timeout:
- self.log.error('No response from subprocess to abort request, terminating it.')
- self.report({'ERROR'}, 'No response from subprocess to abort request, terminating it.')
+ self.log.error(
+ 'No response from subprocess to abort request, terminating it.')
+ self.report(
+ {'ERROR'}, 'No response from subprocess to abort request, terminating it.')
self.process.terminate()
self._finish(context)
return {'CANCELLED'}
@@ -120,10 +124,12 @@ else:
try:
self.process.join(timeout=self._abort_wait)
except multiprocessing.TimeoutError:
- self.log.warning('Subprocess is hanging, terminating it forcefully.')
+ self.log.warning(
+ 'Subprocess is hanging, terminating it forcefully.')
self.process.terminate()
else:
- self.log.debug('Subprocess stopped with exit code %i', self.process.exitcode)
+ self.log.debug(
+ 'Subprocess stopped with exit code %i', self.process.exitcode)
def handle_received_data(self):
recvd = self.pipe_blender.recv()
@@ -134,7 +140,8 @@ else:
except KeyError:
self.log.error('Unable to handle received message %s', recvd)
# Maybe we shouldn't show this to the user?
- self.report({'WARNING'}, 'Unable to handle received message %s' % recvd)
+ self.report(
+ {'WARNING'}, 'Unable to handle received message %s' % recvd)
return
handler(recvd)
@@ -160,9 +167,9 @@ else:
bl_options = {'REGISTER'}
package_name = bpy.props.StringProperty(
- name='package_name',
- description='The name of the package to install'
- )
+ name='package_name',
+ description='The name of the package to install'
+ )
log = logging.getLogger(__name__ + '.PACKAGE_OT_install')
@@ -195,23 +202,26 @@ else:
# TODO: We need other paths besides this one on subprocess end, so it might be better to pass them all at once.
# For now, just pass this one.
- install_path = pathlib.Path(bpy.utils.user_resource('SCRIPTS', 'addons', create=True))
+ install_path = pathlib.Path(
+ bpy.utils.user_resource('SCRIPTS', 'addons', create=True))
self.log.debug("Using %s as install path", install_path)
import addon_utils
proc = mp_context.Process(target=subproc.download_and_install_package,
- args=(self.pipe_subproc, package, install_path))
+ args=(self.pipe_subproc, package, install_path))
return proc
def _subproc_progress(self, progress: messages.Progress):
self.log.info('Task progress at %i%%', progress.progress * 100)
def _subproc_download_error(self, error: messages.DownloadError):
- self.report({'ERROR'}, 'Unable to download package: %s' % error.message)
+ self.report({'ERROR'}, 'Unable to download package: %s' %
+ error.message)
self.quit()
def _subproc_install_error(self, error: messages.InstallError):
- self.report({'ERROR'}, 'Unable to install package: %s' % error.message)
+ self.report({'ERROR'}, 'Unable to install package: %s' %
+ error.message)
self.quit()
def _subproc_success(self, success: messages.Success):
@@ -221,16 +231,21 @@ else:
self.quit()
def _subproc_aborted(self, aborted: messages.Aborted):
- self.report({'ERROR'}, 'Package installation aborted per your request')
+ self.report(
+ {'ERROR'}, 'Package installation aborted per your request')
self.quit()
def report_process_died(self):
if self.process.exitcode:
- self.log.error('Process died without telling us! Exit code was %i', self.process.exitcode)
- self.report({'ERROR'}, 'Error downloading package, exit code %i' % self.process.exitcode)
+ self.log.error(
+ 'Process died without telling us! Exit code was %i', self.process.exitcode)
+ self.report(
+ {'ERROR'}, 'Error downloading package, exit code %i' % self.process.exitcode)
else:
- self.log.error('Process died without telling us! Exit code was 0 though')
- self.report({'WARNING'}, 'Error downloading package, but process finished OK. This is weird.')
+ self.log.error(
+ 'Process died without telling us! Exit code was 0 though')
+ self.report(
+ {'WARNING'}, 'Error downloading package, but process finished OK. This is weird.')
class PACKAGE_OT_uninstall(SubprocMixin, Operator):
bl_idname = 'package.uninstall'
@@ -238,7 +253,8 @@ else:
bl_description = "Remove installed package files from filesystem"
bl_options = {'REGISTER'}
- package_name = bpy.props.StringProperty(name='package_name', description='The name of the package to uninstall')
+ package_name = bpy.props.StringProperty(
+ name='package_name', description='The name of the package to uninstall')
log = logging.getLogger(__name__ + '.PACKAGE_OT_uninstall')
@@ -260,15 +276,15 @@ else:
}
import pathlib
- install_path = pathlib.Path(bpy.utils.user_resource('SCRIPTS', 'addons', create=True))
+ install_path = pathlib.Path(
+ bpy.utils.user_resource('SCRIPTS', 'addons', create=True))
package = bpkg.packages[self.package_name].get_latest_version()
proc = mp_context.Process(target=subproc.uninstall_package,
- args=(self.pipe_subproc, package, install_path))
+ args=(self.pipe_subproc, package, install_path))
return proc
-
def _subproc_uninstall_error(self, error: messages.InstallError):
self.report({'ERROR'}, error.message)
self.quit()
@@ -281,12 +297,15 @@ else:
def report_process_died(self):
if self.process.exitcode:
- self.log.error('Process died without telling us! Exit code was %i', self.process.exitcode)
- self.report({'ERROR'}, 'Error downloading package, exit code %i' % self.process.exitcode)
+ self.log.error(
+ 'Process died without telling us! Exit code was %i', self.process.exitcode)
+ self.report(
+ {'ERROR'}, 'Error downloading package, exit code %i' % self.process.exitcode)
else:
- self.log.error('Process died without telling us! Exit code was 0 though')
- self.report({'WARNING'}, 'Error downloading package, but process finished OK. This is weird.')
-
+ self.log.error(
+ 'Process died without telling us! Exit code was 0 though')
+ self.report(
+ {'WARNING'}, 'Error downloading package, but process finished OK. This is weird.')
class PACKAGE_OT_refresh(SubprocMixin, Operator):
bl_idname = "package.refresh"
@@ -335,23 +354,26 @@ else:
import pathlib
- storage_path = pathlib.Path(bpy.utils.user_resource('CONFIG', 'repositories', create=True))
+ storage_path = pathlib.Path(bpy.utils.user_resource(
+ 'CONFIG', 'repositories', create=True))
repository_urls = [repo.url for repo in self.repositories]
self.log.debug("Repository urls %s", repository_urls)
proc = mp_context.Process(target=subproc.refresh_repositories,
- args=(self.pipe_subproc, storage_path, repository_urls))
+ args=(self.pipe_subproc, storage_path, repository_urls))
return proc
def _subproc_progress(self, progress: messages.Progress):
self.log.info('Task progress at %i%%', progress.progress * 100)
def _subproc_error(self, error: messages.SubprocError):
- self.report({'ERROR'}, 'Unable to refresh package list: %s' % error.message)
+ self.report(
+ {'ERROR'}, 'Unable to refresh package list: %s' % error.message)
self.quit()
def _subproc_download_error(self, error: messages.DownloadError):
- self.report({'ERROR'}, 'Unable to download package list: %s' % error.message)
+ self.report(
+ {'ERROR'}, 'Unable to download package list: %s' % error.me
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list