Testing package imports locally

John Arbash Meinel john at arbash-meinel.com
Wed Feb 17 20:55:07 GMT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Westby wrote:
> On Wed, 17 Feb 2010 11:30:45 -0600, John Arbash Meinel <john at arbash-meinel.com> wrote:
>> When I tried it on 'gnome-panel' it had this error:
>> 54.204  Traceback (most recent call last):
>>   File "./import_package.py", line 769, in main
>>     assert len(versions.plist) > 0
>>   File "./import_package.py", line 211, in get_versions
>>     publications = icommon.lp_call(icommon.call_with_limited_size,
>>   File "./import_package.py", line 172, in get_debian_versions
>>     output, errout = proc.communicate()
>>   File "/usr/lib/python2.6/subprocess.py", line 621, in __init__
>>     errread, errwrite)
>>   File "/usr/lib/python2.6/subprocess.py", line 1126, in _execute_child
>>     raise child_exception
>> OSError: [Errno 2] No such file or directory
> 
> I don't like this error, not helpful at all for working out what is
> wrong, leading me to want to wrap this every time I use it.

Well, pretty much you always have to wrap it, which is a shame. If it
included the path that it couldn't find, it would be a lot clearer.

I did wrap it locally, though my changes include a fair amount of
'other' stuff. So I haven't yet teased apart what should be proposed for
merging. (And in what order)

> 
>> Looking at the code, it seems we also depend on 'madison-lite' being
>> installed. Also, I ran into some bugs wrt not installing
>> 'trace.enable_default_logging()' which meant it wasn't able to tell me
>> what was failing when a plugin failed to load.
> 
> I don't follow, but I'll understand when I see the merge proposal.
> 

If a plugin fails to load during "load_plugins", you'll get:
  "No handlers found for logger: bzr"

This is because you are calling "load_plugins()" before anything is set
up in logging. My current patch looks like:

+from bzrlib import branch, bzrdir, debug, errors, merge, tag, trace,
transport, ui, urlutils
 from bzrlib.plugin import load_plugins
- -from bzrlib.trace import mutter, log_exception_quietly
+from bzrlib.trace import mutter, log_exception_quietly,
enable_default_logging

+# We may not want to do this, but if there is a failure while loading
plugins,
+# it is the only way to find out. One option would be to call
+# 'trace.pop_log_file()' immediately after loading plugins.
+enable_default_logging()
+mutter('import_package started w/ args: %r' % (sys.argv,))
 load_plugins()


I needed to do this because my system bzrlib is 2.0, but my per-user
bzr-builddeb is new enough to require 2.1+. Basically, I have to set
PYTHONPATH (or upgrade the system install). Figuring it out required
enabling logging before loading plugins. (Without it, the initial load
would fail, but couldn't report it, and the *second* import would fail
with a random 'command already registered'.)


>> I'll submit some small patches that should help this a little bit at least.
> 
> Thanks.
> 
> 
> James
> 

Also, while looking, you shouldn't have to do this:
sys.path.insert(0, os.path.dirname(__file__))

That path should always be present when you execute the file directly.
(It would only not be present during an 'import import_package', and
since you don't have an 'if __name__ == "__main__"' clause, it always
runs as a main script.)

I assume at some point the "import icommon" was failing, though.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkt8V6sACgkQJdeBCYSNAAOb8QCfUtyDX/M3chHZDf8g2Lq1SYg6
rK4An0+rt8dE8iNJYDxEkXiKHqcrz9Zs
=FKeg
-----END PGP SIGNATURE-----



More information about the ubuntu-distributed-devel mailing list