Dropbox Forums » Everything Else

Linux CLI in python

(63 posts)
  • Started 1 year ago by Filip L.
  • Latest reply from Matthew P.


RSS feed for this topic


  1. Filip L.
    Member
    Posts: 10

    EDIT:
    After some research I can say that the old CLI is working, but it doesn't do things right, or very nice. And I don't have time to reverse engineer the daemon.
    So I just made a module of some kind that spits out the current status of the daemon, this is really the only thing that I need to get from the daemon anyway.

    The code:
    https://dl.getdropbox.com/u/43645/status.py

    And there's a little example at the bottom of that file explaining how to use the module.

    OLD:
    I havent heard anything about any incoming release of a CLI-client, so I started making my own.

    I've made a small python-class which can communicate with the dropbox-daemon. Such as get file-status and so on.
    But I haven't really figured how the CLI itself should work, got any suggestions?

    What functions does it need to have?

    When I've figured this out, and cleaned the code up a bit I can give it here, if anyone is interested.

    EDIT:
    I've updated the code a bit today, couldn't resist even though my head is killing me.

    Updates to the program/script (whatever):
    - It now tries to start the daemon if it can't connect to it. (if the file exist)
    - It now have an option for downloading and "installing" the daemon (!!!!). Not yet registration though. I will try to fix this asap.
    - It now returns the URL for copygallery, copypublic, browse, revisions etc.
    - The code is now a mess. It will be my project for the weekend to clean it up.

    Link: https://dl.getdropbox.com/u/43645/dbcli.py

    Posted 1 year ago #
  2.  Michael V.
    Pro User
    Posts: 500

    Hi Filip!

    Registration of the client without X would be a nice feature.

    You could use the same command scheme like svn:

    Maybe commands like:

    db geturl <filename>
    For getting the public url of a file in the public or photos folder.

    db share <folder> <mailaddress>
    For sharing a folder with a person.

    db reshare <folder> <mailaddress>
    For resending a share request.

    It's important that is is possible to do the whole setup without any graphics. This includes registration and downloading of the closed source part.

    Michael

    Posted 1 year ago #
  3. Filip L.
    Member
    Posts: 10

    Hello Michael!

    The share-command seems to open up a web-page and does not take any extra arguments, so this will be exactly as in the nautilus-expansion. So I guess the daemon handles all that stuff.

    The geturl (copyurl), and copygallery is also handled by the daemon, and I don't think it'll be a problem doing this part without graphics. It's all about how you've configured your gnome (I guess. it does not work for me, but it's probably because I don't use it).

    Anyhow, I will try to add those commands along with the downloading/updating of the daemon if I figure out how that works today, and hopefully release some kind of code later tonight.

    Posted 1 year ago #
  4.  Oleg S.
    Pro User
    Posts: 81

    Linky please :-)

    Posted 1 year ago #
  5. Filip L.
    Member
    Posts: 10

    The code is now able to run on itself with some minimalistic help information.
    I haven't looked into the start/stop/update on the daemon yet, since I'm sick today (in fever or something :/)

    I will continue on the cleaning- and coding-process tomorrow. I've got the day off.

    Anyway, here's the current code: https://dl.getdropbox.com/u/43645/dbcli.py

    If you find any bugs and/or have any suggestions, please mail me (filip at mkeyd dot net) or write here.

    Posted 1 year ago #
  6.  Michael V.
    Pro User
    Posts: 500

    Hi Filip!

    Thanks for your work! I can't test it by now since my server crashed but I looked into the code.

    Does the closed source part really depends on gnome? Isn't it possible to invoke maybe lynx when registering? And haven't you found a possibility to actually get the public url in return?

    Michael

    Posted 1 year ago #
  7. Sam R.
    Member
    Posts: 4

    Hi Filip!

    I'm getting errors when I run it.

    mca4:~# python
    Python 2.4.4 (#2, Apr 15 2008, 23:43:20)
    [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2

    mca4:~# uname -a
    Linux mca4 2.6.25.15-custom #1 SMP Thu Aug 7 09:42:01 GMT 2008 i686 GNU/Linux

    mca4:~# python dbcli.py
    File "dbcli.py", line 188
    print "%s status: %s" % ("Folder" if (status[0]=="okf") else "File", status[1])
    ^
    SyntaxError: invalid syntax

    Posted 1 year ago #
  8. Vernon J.
    Member
    Posts: 1

    try Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)

    Posted 1 year ago #
  9. Filip L.
    Member
    Posts: 10

    Michael: The only thing one gets in return from the daemon from all those commands (share, browse, copypuplic, copygallery, etc) are 'ok\ndone\n'. There might be other commands that I dont know about.

    Sam: If-statements like that is not supported by python 2.4.x, it got implemented in 2.5.x. Try updating and it'll fix the problem. I can change all those statements to regular if-statements. But I'm afraid I wont be able to do any coding today since I still have fever.

    Posted 1 year ago #
  10. Michael V.
    Member
    Posts: 39

    Hi Filip!

    Have you watched the communication between the nautilus plugin and the deamon?

    Michael

    Posted 1 year ago #
  11. Filip L.
    Member
    Posts: 10

    Michael,

    Yes, almost. I've watched what the nautilus-plugin sends to the daemon.

    Posted 1 year ago #
  12.  Rian H.
    Dropboxer
    Posts: 234

    Filip this is AMAZING. Pretty similar to my CLI client. I get to cheat though, since I can add new commands to dropboxd :P

    You might want to try listening on ~/.dropbox/iface_socket after issuing copypublic / copygallery ;)

    Hope you feel well!

    Posted 1 year ago #
  13. Filip L.
    Member
    Posts: 10

    Rian,

    Ah, that might explain why those commands never worked for me. Thanks. :)
    If our clients are similiar, I guess mine will be obsolete when your client is released :(

    Posted 1 year ago #
  14. Michael V.
    Member
    Posts: 39

    Hi Filip!

    Since Rian seems to be a good coder but does bad documentation ;-) your work is extremly needed for other guys who want to code implementations for e.g. KDE.

    It would be ideal if you built a class that could be reused.

    Michael

    Posted 1 year ago #
  15. Filip L.
    Member
    Posts: 10

    Michael,

    It is already a class, which does all the talking to the daemon. I guess I could do all the action-work in that class as well though. I'll continue the coding tomorrow I think, still too sick to think about this.

    Thank you very much for testing and suggesting features :) I'm glad someone has any kind of use for my code, it's a new experience for me. :p

    Posted 1 year ago #
  16. Filip L.
    Member
    Posts: 10

    I've updated the code a bit today, couldn't resist even though my head is killing me.

    Updates to the program/script (whatever):
    - It now tries to start the daemon if it can't connect to it. (if the file exist)
    - It now have an option for downloading and "installing" the daemon (!!!!). Not yet registration though, I will try to fix this asap.
    - It now returns the URL for copygallery, copypublic, browse, revisions etc.
    - The code is now a mess. It will be my project for the weekend to clean it up.

    Link: https://dl.getdropbox.com/u/43645/dbcli.py

    Posted 1 year ago #
  17.  Arash F.
    Dropboxer
    Posts: 3075

    nice work :)

    Posted 1 year ago #
  18. Filip L.
    Member
    Posts: 10

    Thank you, Arash :)

    Posted 1 year ago #
  19. Alia B.
    Member
    Posts: 1

    Do we know if Rian's cli client will run via Python as well?

    Also, any update? I've been playing with Filip's client, but Python isn't playing nicely with some other items I have..

    Posted 1 year ago #
  20. Filip L.
    Member
    Posts: 10

    Hi Alia!

    I'm sorry to hear that, what are you trying to do that causes trouble? This is the positive about open source, you can just modify the code by yourself, if you have the knowledge.

    I don't know about Rian's client, but I have reason to believe that the dropboxd is fully or partly made in python. If you crash it, it gives messages stating that some modules/whatever including python raised errors.

    Posted 1 year ago #
  21. Dan C.
    Member
    Posts: 2

    Does one need to have nautilus and gnome installed to run Filip's python client? I cant seem to start dropboxd without it crashing on me.

    -Dan

    Posted 1 year ago #
  22.  Tek B.
    Pro User
    Posts: 13

    Had to update Python to get it to work here...

    Any progress on getting the link'ng done without having to have a GUI?

    Posted 1 year ago #
  23. Filip L.
    Member
    Posts: 10

    The registration is completely done by the daemon itself, so I cant do anything about that, sorry :/.
    Seems like we're stuck with X deps. until they release a new version of the dropboxd that does not need any X-libraries.

    One could emulate the program and let it believe that it has those libraries, and then just don't show any GUI. But I think that'll take longer time to develop than it will take for the new daemon to be released.

    Posted 1 year ago #
  24. Josh A.
    Member
    Posts: 1

    How do you uninstall this?

    how do you configure/register this? I have a headless server so X isnt an option...

    Posted 1 year ago #
  25. Filip L.
    Member
    Posts: 10

    Josh, the daemon handles the registration. My script only downloads the daemon, unpacks it in ~/.dropbox-dist/ and runs ~/.dropbox-dist/dropboxd.
    And then it communicate with the daemon through ~/.dropbox/*_socket.

    So if you want to use it on a X-free system, you'll have to wait for a new release of the dropboxd.

    Posted 1 year ago #
  26. Josh A.
    Member
    Posts: 1

    "So if you want to use it on a X-free system, you'll have to wait for a new release of the dropboxd."

    bummer, what a deal breaker... :/

    So do I just remove .dropbox & .dropbox-dist to "uninstall" it?

    Posted 1 year ago #
  27. Filip L.
    Member
    Posts: 10

    Yes, that's correct.

    Posted 1 year ago #
  28.  Tek B.
    Pro User
    Posts: 13

    Perhaps Rian will stop by our lil thread and with wonderful news in the next day or so and say that, there is a new dropboxd that is free of pollutants we call X.. ;)

    Posted 1 year ago #
  29. Filip L.
    Member
    Posts: 10

    One can only hope. He's been here once though. But not with news like that, only stated that he could cheat, and that I couldn't :(

    Posted 1 year ago #
  30.  Michael N.
    Dropboxer
    Posts: 2428

    Thats not all he said, he said your work was amazing too :)

    Posted 1 year ago #

Reply »

You must log in to post.

Dropbox Forums is proudly powered by bbPress.

Protected by Arash