support command line arguments

Bug #790301 reported by Spoilerhead on 2011-05-30
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyShare
Wishlist
Unassigned

Bug Description

It would be very cool if PyShare would support command line arguments, too, so it could be used from other applications, too (i.e. in my case thunar and bibble5)

I'm not really into python, but for me the following hack to sendFiles works:

if __name__ == "__main__":
    if environ.has_key('NAUTILUS_SCRIPT_SELECTED_URIS'):
        files = environ['NAUTILUS_SCRIPT_SELECTED_URIS'].splitlines()
        uploadFilesGUI(files)
    else:
#parse command line arguments of no nautilus environment is found
        files = sys.argv[1:]
        uploadFilesGUI(files)

Well you can already run first branch of if by calling sendFiles script and else branch by invoking PyShare_GTK.py.
Could you specify what behavior exactly would you expect? (I have some ideas about improving CLI support, but would like to hear your idea).

Changed in pyshare:
status: New → Incomplete
importance: Undecided → Wishlist
Spoilerhead (spoilerhead) wrote :

Oh, I got to try that when I get home.

What I try to do:
* use it in Thunar as a custom user action, i.e. right click on a file -> sendfiles . Thunar can call a script with the filenames in argv
* use it in Bibble5 (a raw development/image management tool) to upload directly to imageshack. again, a script can be called with the filename as parameter.
* i bet other users can think about a multitude of other uses :)

I remember that people used old PyShare versions with Thunar actions successfully. About 0.4.0 I introduced a problem for them with setting "allow only one instance" which relied on DBus. If you don't have dbus installed you may want to turn this setting of.
As PyShare would probably wont run here is nasty workaround:
change this lines in Settings.py from
86 def getAllowOneInstanceOnly(self):
87 return self.__settings["allowOneInstanceOnly"]

to :
     def getAllowOneInstanceOnly(self):
        return false

I cannot check it at the moment, because I don't have any XFCE only distro installed.

In the future I plan to split PyShare on several packages(unfortunately i don't have any experience with packaging). Please see https://blueprints.launchpad.net/pyshare/+spec/packaging and tell me if it CLI package would be appropriate solution in your opinion.

Spoilerhead (spoilerhead) wrote :

that takes me a step further
unfortunately it fails instantly with "Upload failed"

The console output is just
translations for your language don't yet exist
translations for your language don't yet exist

(i just upgraded to 0.6.2rc, previously hacked around in 0.5.2)

This is on a Xubuntu 11.04 machine btw, but i can test on a pure xfce crunchbang, too if needed.

Could you take a look at the ~/.pyshare/errorLog ? If there is something there please post it. Not existing translations should not be fatal.

Spoilerhead (spoilerhead) wrote :

ERROR:pluginWrapper:
Traceback (most recent call last):
  File "/home/spoilerhead/system/PyShare62/pluginWrapper.py", line 46, in __runMethod
    apply(method, arguments)
  File "/home/spoilerhead/system/PyShare62/pluginWrapper.py", line 96, in __createUploaderInstanceAndUploadFile
    credentials = Settings().getUploaderCredentials(uploader.NAME)
  File "/home/spoilerhead/system/PyShare62/Settings.py", line 146, in getUploaderCredentials
    key = Keyring(self.__keyringName)
  File "/home/spoilerhead/system/PyShare62/Singleton.py", line 25, in __call__
    cls.instance = super(Singleton, cls).__call__(*args, **kw)
  File "/home/spoilerhead/system/PyShare62/Keyring.py", line 34, in __init__
    "proxy": None})
  File "/home/spoilerhead/system/PyShare62/Keyring.py", line 100, in _override_old_passwords
    if self._new_passwords_exists():
  File "/home/spoilerhead/system/PyShare62/Keyring.py", line 93, in _new_passwords_exists
    items = gkey.find_items_sync(gkey.ITEM_NETWORK_PASSWORD, attrs)
NoMatchError

Spoilerhead (spoilerhead) wrote :

Seems to work, thank you very much!

Glad to here that.
I don't longer know how to categorize this "bug" so I will close it as invalid. If you come up with more specific title and description what was fixed/or needs to be improved you may reopen this bug or make a new one.

Changed in pyshare:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers