Flags are treated as arguments if they come first

Bug #906278 reported by Jonathan Lange
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pkgme-devportal
Fix Released
High
Unassigned

Bug Description

$ PYTHONPATH=. ./bin/fetch-symbol-files --database_path=local.db husathuaseouhhtai

will try to download source for the package '--database_path=local.db', rather than the expected 'husathuaseouhhtai'.

Related branches

Revision history for this message
James Westby (james-w) wrote : Re: [Bug 906278] [NEW] Flags are treated as arguments if they come first

On Mon, 19 Dec 2011 12:23:34 -0000, Jonathan Lange <email address hidden> wrote:
> Public bug reported:
>
> $ PYTHONPATH=. ./bin/fetch-symbol-files --database_path=local.db
> husathuaseouhhtai
>
> will try to download source for the package '--database_path=local.db',
> rather than the expected 'husathuaseouhhtai'.

There's two things here:

  1. bin/fetch-symbol-files is just using argv[1], rather than using
  optparse or anything, which is why it's acting on the option.

  2. as optparse isn't being used configglue hasn't got anything to hook
  to, so --database_path wouldn't do anything useful anyway at this
  time.

The first is pretty easy to fix, the second probably needs a bit of
reworking of the config code to pull it up a couple of levels, and test
changes to adjust to that.

Thanks,

James

Changed in pkgme-binary:
status: New → Incomplete
status: Incomplete → Triaged
importance: Undecided → High
Revision history for this message
Jonathan Lange (jml) wrote :

I grok 1.

However, fetch-symbol-files does not work for me unless I specify --database_path. e.g.

$ PYTHONPATH=. ./bin/fetch-symbol-files openssh-client
Traceback (most recent call last):
  File "./bin/fetch-symbol-files", line 15, in <module>
    sys.exit(main())
  File "./bin/fetch-symbol-files", line 11, in main
    database.main(sys.argv[1])
  File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 424, in main
    db = PackageDatabase.create()
  File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 350, in create
    store, store_type = cls.get_store_from_config()
  File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 343, in get_store_from_config
    connection_string, store_type = cls.get_db_info_from_config()
  File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 329, in get_db_info_from_config
    connection_string = cls._get_storm_connection_string(opts)
  File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 314, in _get_storm_connection_string
    return cls._get_storm_sqlite_connection_string(opts)
  File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 295, in _get_storm_sqlite_connection_string
    % (cls.ENV_VAR,))
ValueError: Cannot create database, no path given and PKGME_LIB_DEPS_DB_PATH not set
$ PYTHONPATH=. ./bin/fetch-symbol-files openssh-client --database_path=local.db

Revision history for this message
James Westby (james-w) wrote : Re: [Bug 906278] Re: Flags are treated as arguments if they come first

On Tue, 20 Dec 2011 18:27:39 -0000, Jonathan Lange <email address hidden> wrote:
> I grok 1.
>
> However, fetch-symbol-files does not work for me unless I specify
> --database_path. e.g.
>
> $ PYTHONPATH=. ./bin/fetch-symbol-files openssh-client
> Traceback (most recent call last):
> File "./bin/fetch-symbol-files", line 15, in <module>
> sys.exit(main())
> File "./bin/fetch-symbol-files", line 11, in main
> database.main(sys.argv[1])
> File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 424, in main
> db = PackageDatabase.create()
> File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 350, in create
> store, store_type = cls.get_store_from_config()
> File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 343, in get_store_from_config
> connection_string, store_type = cls.get_db_info_from_config()
> File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 329, in get_db_info_from_config
> connection_string = cls._get_storm_connection_string(opts)
> File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 314, in _get_storm_connection_string
> return cls._get_storm_sqlite_connection_string(opts)
> File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 295, in _get_storm_sqlite_connection_string
> % (cls.ENV_VAR,))
> ValueError: Cannot create database, no path given and PKGME_LIB_DEPS_DB_PATH not set
> $ PYTHONPATH=. ./bin/fetch-symbol-files openssh-client --database_path=local.db

I guess I should have changed the error message there to include that
there is no config file. Until this is fixed you can create

  ~/.config/pkgme-binary/conf

according to the README: i.e. with

  [database]
  db_type = sqlite
  path = /path/to/file.db

Hooking up configglue to allow specifying this on the command line would
be a good thing too.

Thanks,

James

Revision history for this message
Jonathan Lange (jml) wrote :

On Tue, Dec 20, 2011 at 6:49 PM, James Westby <email address hidden> wrote:
> On Tue, 20 Dec 2011 18:27:39 -0000, Jonathan Lange <email address hidden> wrote:
>> I grok 1.
>>
>> However, fetch-symbol-files does not work for me unless I specify
>> --database_path. e.g.
>>
>> $ PYTHONPATH=. ./bin/fetch-symbol-files openssh-client
>> Traceback (most recent call last):
>>   File "./bin/fetch-symbol-files", line 15, in <module>
>>     sys.exit(main())
>>   File "./bin/fetch-symbol-files", line 11, in main
>>     database.main(sys.argv[1])
>>   File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 424, in main
>>     db = PackageDatabase.create()
>>   File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 350, in create
>>     store, store_type = cls.get_store_from_config()
>>   File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 343, in get_store_from_config
>>     connection_string, store_type = cls.get_db_info_from_config()
>>   File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 329, in get_db_info_from_config
>>     connection_string = cls._get_storm_connection_string(opts)
>>   File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 314, in _get_storm_connection_string
>>     return cls._get_storm_sqlite_connection_string(opts)
>>   File "/home/jml/src/pkgme-binary/source-and-binary/devportalbinary/database.py", line 295, in _get_storm_sqlite_connection_string
>>     % (cls.ENV_VAR,))
>> ValueError: Cannot create database, no path given and PKGME_LIB_DEPS_DB_PATH not set
>> $ PYTHONPATH=. ./bin/fetch-symbol-files openssh-client --database_path=local.db
>
> I guess I should have changed the error message there to include that
> there is no config file. Until this is fixed you can create
>
>  ~/.config/pkgme-binary/conf
>
> according to the README: i.e. with
>
>  [database]
>  db_type = sqlite
>  path = /path/to/file.db
>
> Hooking up configglue to allow specifying this on the command line would
> be a good thing too.
>

I should point out that when I specify database_path on the command
line it creates a file of that name and puts stuff in it.

jml

Revision history for this message
James Westby (james-w) wrote :

On Tue, 20 Dec 2011 19:01:12 -0000, Jonathan Lange <email address hidden> wrote:
> I should point out that when I specify database_path on the command
> line it creates a file of that name and puts stuff in it.

configglue must have more magic in it than I thought :-)

I guess 1 is all that needs fixing then.

Thanks,

James

Changed in pkgme-binary:
status: Triaged → Fix Committed
Jonathan Lange (jml)
Changed in pkgme-devportal:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.