venerdì 29 aprile 2011

Dropbox Uploader dalla fonera 2.0n e openwrt

Sulla pagina wiki degli addons di dropboxce ne sono alcuni teroicamente compatibili con qualsiasi sistema, si può usare il uno script in bash, php o python sfruttando la pagina web per l'upload oppure utilizzare il protocollo webDAV. Tutte le soluzioni però limitano l'upload a file di dimensione inferiore ai 300MB, condizione dettata da Dropbox per chi non usa la loro applicazione (disponibile solo per x86).

Lo script in bash + curl non ne ha voluto sapere di funzionare. All'apparenza va tutto a buon fine ma alla richiesta della pagina per l'uploading riceve errore 500 (su ubuntu lo script funziona).

L'uploader in python invece sembra funzionare correttamente ed molto semplice da usare. L'unica dipendenza mancante sul repo di nslu2-linux.orgè il modulo per python mechanize. facilemente installabile se python è ben configurato.
Dopo avere installato ipkg-opt sulla fonera basta seguire questi pochi passaggi:

ipkg install py25-setuptools
easy_install-2.5 mechanize

Scarichiamo e proviamo il tutto ;P
cd /tmp/mounts/Disc-A1/
wget http://download.github.com/jncraton-PythonDropboxUploader-b037ca1.tar.gz
tar zxvf jncraton-PythonDropboxUploader-b037ca1.tar.gz
mv jncraton-PythonDropboxUploader-b037ca1/ PythonDropboxUploader
cd /tmp/mounts/Disc-A1/PythonDropboxUploader/src/
python example.py

Lo script example.py oltre a dare un'idea di come poter usare il programmino uppa nella cartella di dropbox il file dbupload_test.txt con all'interno lo stesso contenuto dello script.
Nel caso il link qui sotto non dovesse funzionare il programma si trova all'indirizzo https://github.com/jncraton/PythonDropboxUploader, copiare il link dal pulsante download, sostituire http a https e lasciarlo scaricare a wget nella directory desiderata.
Qui una breve guida al pacchetto, del resto non c'è molto da spiegare.

Per finire la soluzione con webDAV personalmente non l'ho ritenuta la migliore perchè bisogna associare il proprio account su http://www.dropdav.com/ e se non ho capito male i propri file uploadati tramite questo sistema passano per dei loro server. Ad ogni modo c'è potrebbe ritenerlo utile.
Come client webDAV ho trovato cadaver su optware e per automatizzare la connessione senza perderci troppo tempo ho usato empty (un sostituto di tcl/expect) che però è solo sul repositry di openwrt.

ipkg install cadaver
opkg -dest usb install empty
lo script:
vi /usr/sbin/emptycadaver.sh
#!/bin/sh
empty -f -i in -o out /opt/bin/cadaver https://dav.dropdav.com/
empty -w -i out -o in "Do you wish to accept the certificate" "y\n"
empty -w -i out -o in "Username:" "USERNAME@EMAIL.COM\n"
empty -w -i out -o in "Password:" "PASSWORD\n"
empty -w -i out -o in "dav:" "put /tmp/mounts/Disc-A1/PERCORSO_FILE\n"
empty -w -i out -o in "dav:" "quit\n"

Un ringraziamento è dovuto al mio compare Chronocento che tra le altre cose mi ha fatto conoscere la community FON e Dropbox.
Fonti:
http://wiki.dropbox.com/DropboxAddons/PythonDropboxUploader
http://wiki.dropbox.com/DropboxAddons
http://mattsprinsky.com/blog/2009/02/13/using-expect-and-cadaver-to-automate-webdav-uploads

6 commenti:

  1. nice post.

    the best picture which are taken by mobile phone, you can find here amazing 'mobile phone photography'.
    for seeing images click here "Mobile Photography"

    RispondiElimina
  2. The collection Marts can Helps you to find latest trends. We have latest designs at comforter Set, Bed Sheets, Sofa Covers, Baby Comforter Set, Pillow Covers, Blankets and much more. Our Service is provide high Quality Stuff and Satisfaction of customer. You can view latest desigsn at our facebook page. https://web.facebook.com/The-Collection-Marts-317300915823297/.
    bed sheets sale , khadi clothes for ladies , bed sheets sale , nishat linen bed sheets online , luxury bedspreads , bedspreads and comforters , jaipuri razai double bed price , sofa covers cheap , buy cushions

    RispondiElimina
  3. ViajeroCasual.com es un proyecto web con la finalidad de ofrecer los mejores reportajes turísticos de todos los lugares del mundo. Podrás encontrar artículos de las comidas típicas, artículos acerca de los mejores lugares para ver y visitar, guías turísticas, costumbres o vestimentas típicas, cultura, mejores épocas para viajar y muchísimo más. El objetivo de Viajero Casual es traerte toda la información para que tu próximo viaje sea lo más cómodo posible, y no sólo eso, sino también si quieres ver y descubrir mundo sin salir de casa en nuestro blog.

    Más información sobre Viajero Casual en: Viajero Casual

    RispondiElimina
  4. Exactly what i was looking for. Can you write on best ayurveda clinic in dubai as well.

    RispondiElimina
  5. Fix an every day financial plan to keep away from liquidation. On the off chance that you wager without appropriate arranging, at that point you will very before long land up in a monetary emergency. Likewise set an objective for winning. On the off chance that you arrive at your objective, at that point stop and save the rest for the following day. Try not to continue betting in light of the fact that by the day's end you will locate that neither you have your cash nor the rewards to bring home. There are a few days when you locate that regardless of what you play, eventually you free. In such a day, it is prudent to stop and save the extra for the following day. A few people when they find that they can't dominate a solitary match, they continue betting on different games and at last they land up wrecked.

    Read more text: satta bajar

    RispondiElimina