Skip to content

Commit

Permalink
Merge branch 'master' into 'invalid-pipeline-hides-package-errors_/lo…
Browse files Browse the repository at this point in the history
…ops'
  • Loading branch information
remram44 committed Oct 9, 2014
2 parents 80804b9 + eb877d1 commit 34d1d86
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 77 deletions.
16 changes: 9 additions & 7 deletions vistrails/core/configuration.py
Expand Up @@ -128,9 +128,9 @@
useMacBrushedMetalStyle: Use a brushed metal interface (MacOS X only)
user: The username for the database to the load vistrail from
userPackageDir: Local packages directory
viewOnLoad: Whether to show pipeline or history view when opening vistrail
webRepositoryURL: Web repository URL
webRepositoryUser: Web repository username
viewOnLoad: Whether to show pipeline or history view when opening vistrail
withVersionTree: Output the version tree as an image
withWorkflow: Output the workflow graph as an image
"""
Expand Down Expand Up @@ -496,6 +496,11 @@
The location for user-installed packages (defaults to
~/.vistrails/userpackages).
viewOnLoad: String
Whether to show pipeline or history view when opening vistrail
Can be either appropriate/pipeline/history
webRepositoryURL: URL
The URL of the web repository that should be attached to VisTrails
Expand All @@ -506,11 +511,6 @@
The default username for logging into a VisTrails web repository
like crowdLabs.
viewOnLoad: String
Whether to show pipeline or history view when opening vistrail
Can be either appropriate/pipeline/history
withVersionTree: Boolean
Output the version tree as an image.
Expand Down Expand Up @@ -644,7 +644,9 @@ def __init__(self, name, sub_fields):
widget_type="combo",
widget_options={"allowed_values": [".vt", ".xml"],
"label": "Default File Type/Extension"}),
ConfigField('debugLevel', 0, int, widget_type="combo",
ConfigField('debugLevel', 0, int,
flag='-v',
widget_type="combo",
widget_options={"allowed_values": [0,1,2],
"label": "Show alerts for",
"remap": {0: "Critical Errors Only",
Expand Down
2 changes: 1 addition & 1 deletion vistrails/core/debug.py
Expand Up @@ -216,7 +216,7 @@ def make_logger(self, f=None):
# Then we define a handler to log to the console
self.console = logging.StreamHandler()
self.console.setFormatter(self.format)
self.console.setLevel(logging.WARNING)
self.console.setLevel(logging.DEBUG)

# We also propagate to a second logger, that API users might want to
# configure
Expand Down
111 changes: 46 additions & 65 deletions vistrails/core/packagemanager.py
Expand Up @@ -904,69 +904,50 @@ class TestImports(unittest.TestCase):
def test_package(self):
from vistrails.tests.utils import MockLogHandler

# Hacks PackageManager so that it temporarily uses our test package
# instead of userpackages
pm = get_package_manager()
from vistrails.tests.resources import import_pkg
def fake_userpkg_mod():
pm._userpackages = import_pkg
return import_pkg
old_userpackages = pm._userpackages
old_import_userpackages = pm.import_user_packages_module
pm._userpackages = import_pkg
pm.import_user_packages_module = fake_userpkg_mod

old_fix_names = list(Package.FIX_PACKAGE_NAMES)
Package.FIX_PACKAGE_NAMES.append('tests.resources.import_targets')

try:
# Check the package is in the list
available_pkg_names = pm.available_package_names_list()
self.assertIn('test_import_pkg', available_pkg_names)

# Import __init__ and check metadata
pkg = pm.look_at_available_package('test_import_pkg')
with MockLogHandler(debug.DebugPrint.getInstance().logger) as log:
pkg.load('vistrails.tests.resources.import_pkg.')
self.assertEqual(len(log.messages['warning']), 1)
self.assertEqual(pkg.identifier,
'org.vistrails.tests.test_import_pkg')
self.assertEqual(pkg.version,
'0.42')
for n in ['vistrails.tests.resources.import_targets.test1',
'vistrails.tests.resources.import_targets.test2']:
self.assertIn(n, sys.modules, "%s not in sys.modules" % n)

# Import init.py
pm.late_enable_package(
'test_import_pkg',
{'test_import_pkg':
'vistrails.tests.resources.import_pkg.'})
pkg = pm.get_package_by_codepath('test_import_pkg')
for n in ['vistrails.tests.resources.import_targets.test3',
'vistrails.tests.resources.import_targets.test4',
'vistrails.tests.resources.import_targets.test5']:
self.assertIn(n, sys.modules, "%s not in sys.modules" % n)

# Check dependencies
deps = pkg.get_py_deps()
for dep in ['vistrails.tests.resources.import_pkg.test_import_pkg',
'vistrails.tests.resources.import_pkg.test_import_pkg.init',
'vistrails.tests.resources.import_pkg.test_import_pkg.module1',
'vistrails.tests.resources.import_pkg.test_import_pkg.module2',
'vistrails.tests.resources.import_targets',
'vistrails.tests.resources.import_targets.test1',
'vistrails.tests.resources.import_targets.test2',
'vistrails.tests.resources.import_targets.test3',
'vistrails.tests.resources.import_targets.test4',
'vistrails.tests.resources.import_targets.test5',
'vistrails.tests.resources.import_targets.test6']:
self.assertIn(dep, deps)
finally:
pm._userpackages = old_userpackages
pm.import_user_packages_module = old_import_userpackages
Package.FIX_PACKAGE_NAMES = old_fix_names
try:
pm.late_disable_package('test_import_pkg')
except MissingPackage:
pass
pm.get_available_package(
'test_import_pkg',
prefix='vistrails.tests.resources.import_pkg.')

# Check the package is in the list
available_pkg_names = pm.available_package_names_list()
self.assertIn('test_import_pkg', available_pkg_names)

# Import __init__ and check metadata
pkg = pm.look_at_available_package('test_import_pkg')
with MockLogHandler(debug.DebugPrint.getInstance().logger) as log:
pkg.load('vistrails.tests.resources.import_pkg.')
self.assertEqual(len(log.messages['warning']), 1)
self.assertEqual(pkg.identifier,
'org.vistrails.tests.test_import_pkg')
self.assertEqual(pkg.version,
'0.42')
for n in ['vistrails.tests.resources.import_targets.test1',
'vistrails.tests.resources.import_targets.test2']:
self.assertIn(n, sys.modules, "%s not in sys.modules" % n)

# Import init.py
pm.late_enable_package(
'test_import_pkg',
{'test_import_pkg':
'vistrails.tests.resources.import_pkg.'})
pkg = pm.get_package_by_codepath('test_import_pkg')
for n in ['vistrails.tests.resources.import_targets.test3',
'vistrails.tests.resources.import_targets.test4',
'vistrails.tests.resources.import_targets.test5']:
self.assertIn(n, sys.modules, "%s not in sys.modules" % n)

# Check dependencies
deps = pkg.get_py_deps()
for dep in ['vistrails.tests.resources.import_pkg.test_import_pkg',
'vistrails.tests.resources.import_pkg.test_import_pkg.init',
'vistrails.tests.resources.import_pkg.test_import_pkg.module1',
'vistrails.tests.resources.import_pkg.test_import_pkg.module2',
'vistrails.tests.resources.import_targets',
'vistrails.tests.resources.import_targets.test1',
'vistrails.tests.resources.import_targets.test2',
'vistrails.tests.resources.import_targets.test3',
'vistrails.tests.resources.import_targets.test4',
'vistrails.tests.resources.import_targets.test5',
'vistrails.tests.resources.import_targets.test6']:
self.assertIn(dep, deps)
4 changes: 2 additions & 2 deletions vistrails/core/startup.py
Expand Up @@ -315,12 +315,12 @@ def setup_debug(self):
msg = ("""Don't know how to set verboseness level to %s - "
"setting to the lowest one I know of: 0""" % verbose)
debug.critical(msg)
verbose = 0
verbose = self.temp_configuration.debugLevel = 0
if verbose > 2:
msg = ("""Don't know how to set verboseness level to %s - "
"setting to the highest one I know of: 2""" % verbose)
debug.critical(msg)
verbose = 2
verbose = self.temp_configuration.debugLevel = 2
dbg = debug.DebugPrint.getInstance()
levels = [dbg.WARNING, dbg.INFO, dbg.DEBUG]
dbg.set_message_level(levels[verbose])
Expand Down
4 changes: 2 additions & 2 deletions vistrails/gui/preferences.py
Expand Up @@ -740,5 +740,5 @@ def test_remove_package(self):

# check if configuration has been written correctly
startup = _app.startup
self.assertTrue(pkg in startup.disabled_packages)
self.assertTrue(pkg not in startup.enabled_packages)
self.assertIn(pkg, startup.disabled_packages)
self.assertNotIn(pkg, startup.enabled_packages)
5 changes: 5 additions & 0 deletions vistrails/tests/runtestsuite.py
Expand Up @@ -96,6 +96,9 @@ def clean(self):
default=0, dest="verbose",
help="set verboseness level(0--2, default=0, "
"higher means more verbose)")
parser.add_option("-v", "--vistrails-verbose", action="store", type="int",
default=0, dest="debugLevel",
help="set the debugLevel in VisTrails (0--2, default=0)")
parser.add_option("-e", "--examples", action="store_true",
default=False,
help="run vistrails examples")
Expand Down Expand Up @@ -129,6 +132,7 @@ def clean(self):
installbundles = options.installbundles
dotVistrails = options.dotVistrails
debug_mode = options.debug
vistrails_verbose = options.debugLevel

# Makes stdout unbuffered, so python -u is not needed
class Unbuffered(object):
Expand Down Expand Up @@ -247,6 +251,7 @@ def module_filter(name):
'enablePackagesSilently': True,
'handlerDontAsk': True,
'developerDebugger': debug_mode,
'debugLevel': vistrails_verbose
}
if dotVistrails:
optionsDict['dotVistrails'] = dotVistrails
Expand Down

0 comments on commit 34d1d86

Please sign in to comment.