Skip to content

Commit

Permalink
Fixes to core.upgradeworkflow
Browse files Browse the repository at this point in the history
UnboundLocalError could happen in replace_generic():
    local variable 'basic_pkg' referenced before assignment
  • Loading branch information
remram44 committed Apr 21, 2014
1 parent 62b10b9 commit af4b8d4
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions vistrails/core/upgradeworkflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
from vistrails.core.modules.module_registry import get_module_registry, \
ModuleDescriptor, MissingModule, MissingPort, MissingPackage
from vistrails.core.modules.utils import parse_descriptor_string, \
create_descriptor_string, parse_port_spec_string, \
create_port_spec_string, expand_port_spec_string
create_descriptor_string, parse_port_spec_string, create_port_spec_string
from vistrails.core.packagemanager import get_package_manager
from vistrails.core.system import get_vistrails_basic_pkg_id
from vistrails.core.vistrail.annotation import Annotation
Expand Down Expand Up @@ -199,7 +198,6 @@ class UpgradeWorkflowHandler(object):

@staticmethod
def dispatch_request(controller, module_id, current_pipeline):
reg = get_module_registry()
pm = get_package_manager()
if module_id not in current_pipeline.modules:
# It is possible that some other upgrade request has
Expand All @@ -226,7 +224,7 @@ def dispatch_request(controller, module_id, current_pipeline):
@staticmethod
def check_port_spec(module, port_name, port_type, descriptor=None,
sigstring=None):
from vistrails.core.modules.basic_modules import identifier as basic_pkg
basic_pkg = get_vistrails_basic_pkg_id()

reg = get_module_registry()
found = False
Expand Down Expand Up @@ -262,8 +260,6 @@ def check_port_spec(module, port_name, port_type, descriptor=None,

@staticmethod
def find_descriptor(controller, pipeline, module_id, desired_version=''):
from vistrails.core.modules.abstraction \
import identifier as local_abstraction_pkg
reg = get_module_registry()

get_descriptor = reg.get_descriptor_by_name
Expand Down Expand Up @@ -356,7 +352,7 @@ def attempt_automatic_upgrade(controller, pipeline, module_id,
else:
nss = mname
msg = ("Could not upgrade module %s from package %s.\n" %
(mname, mpkg))
(nss, mpkg))
raise UpgradeWorkflowError(msg)

UpgradeWorkflowHandler.check_upgrade(pipeline, module_id, d,
Expand Down Expand Up @@ -420,6 +416,8 @@ def replace_generic(controller, pipeline, old_module, new_module,
function_remap={}, src_port_remap={},
dst_port_remap={}, annotation_remap={},
use_registry=True):
basic_pkg = get_vistrails_basic_pkg_id()

ops = []
ops.extend(controller.delete_module_list_ops(pipeline, [old_module.id]))

Expand Down Expand Up @@ -497,8 +495,6 @@ def replace_generic(controller, pipeline, old_module, new_module,
if use_registry:
function_port_spec = function_name
else:
reg = get_module_registry()
basic_pkg = get_vistrails_basic_pkg_id()
def mk_psi(pos):
psi = PortSpecItem(module="Module", package=basic_pkg,
namespace="", pos=pos)
Expand Down Expand Up @@ -585,8 +581,8 @@ def mk_psi(pos):

@staticmethod
def replace_group(controller, pipeline, module_id, new_subpipeline):
old_group = pipeline.modules[module_id]
basic_pkg = get_vistrails_basic_pkg_id()
old_group = pipeline.modules[module_id]
new_group = controller.create_module(basic_pkg, 'Group', '',
old_group.location.x,
old_group.location.y)
Expand Down Expand Up @@ -805,7 +801,6 @@ def create_workflow(self, c):
return c.current_version

def run_multi_upgrade_test(self, pkg_remap):
from vistrails.core.packagemanager import get_package_manager
from vistrails.core.application import get_vistrails_application

app = get_vistrails_application()
Expand Down Expand Up @@ -874,7 +869,6 @@ def test_multi_upgrade_rename(self):
self.run_multi_upgrade_test(pkg_remap)

def test_external_upgrade(self):
from vistrails.core.packagemanager import get_package_manager
from vistrails.core.application import get_vistrails_application

app = get_vistrails_application()
Expand Down

0 comments on commit af4b8d4

Please sign in to comment.