搜索
Hi~登录注册
查看: 3422|回复: 0

linux利用python自动同步到百度云盘

[复制链接]

1892

主题

1899

帖子

6406

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
6406
发表于 2016-1-7 22:50:40 | 显示全部楼层 |阅读模式
1.首先git一份
  1. cd ~
  2.     mkdir bdyun
  3.     cd bdyun
  4.     git clone https://github.com/houtianze/bypy.git
复制代码


然后
进入/etc/sysconfig/i18n
编辑内容为
  1. LANG="zh_CN.UTF-8"
  2. SYSFONT=latarcyrheb-sun16
复制代码
接下来执行
  1. wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
  2. tar -xvf Python-2.7.8.tar.xz
  3. cd Python-2.7.8
  4. ./configure
  5. make
  6. su
  7. make install
复制代码
执行完毕后执行
  1. wget https://bootstrap.pypa.io/ez_setup.py -O - | python
复制代码
把最新的setuptools-19.2.zip解压
  1. unzip setuptools-19.2.zip
复制代码
然后在解压后的目录执行
  1. python ez_setup.py
复制代码
执行完毕后安装要求包
  1. easy_install requests
复制代码
安装完毕即完成
完成以上安装,cd至之前的clone的目录下,运行下面的命令开始初始化
./bypy list
首先他会要求你访问一个网址,需要你授权,授权后复制code给程序,如果没有报错,就可以看到你的同步目录了,你可以在网盘的我的应用数据文件夹里找到bypy文件夹,他就是应用目录了。
如果你迫不及待的要测试,那就试试直接把当前目录上传至百度网盘
./bypy upload
如果你想看到上传进度,请加入-v选项
./bypy -v upload
剩下的就不用说了吧,话说国外服务器上传的速度不太给力啊!
下面是bypy命令一览表
python -m bypy
usage: bypy.py [-h] [-V] [-d] [-v] [-r RETRY] [-q QUIT] [-t TIMEOUT]
               [-s SLICE] [--chunk CHUNK] [-e] [-f]
               [--resume-download RESUMEDL] [--include-regex INCREGEX]
               [--on-dup ONDUP] [--no-symlink] [--disable-ssl-check]
               [--cacerts CACERTS] [--mirror MIRROR] [--rapid-upload-only]
               [-c]
               [command [command ...]]


bypy.py v1.2.9 - Python client for Baidu Yun (https://github.com/houtianze/bypy)
It provides file operations like: list, download, upload, syncup, syncdown, etc.


The main purpose is to utilize Baidu Yun in Linux environments (e.g. Raspberry Pi)


For more information, please refer to https://github.com/houtianze/bypy


positional arguments:
  command               operations (quota, list, etc)


optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -d, --debug           set debugging level (-dd to increase debugging level,
                        -ddd to enable HTPP traffic debugging as well (very
                        talkative)) [default: 0]
  -v, --verbose         set verbosity level [default: 0]
  -r RETRY, --retry RETRY
                        number of retry attempts on network error [default: 5

  -q QUIT, --quit-when-fail QUIT
                        quit when maximum number of retry failed [default:

  -t TIMEOUT, --timeout TIMEOUT
                        network timeout in seconds [default: 60]
  -s SLICE, --slice SLICE
                        size of file upload slice (can use '1024', '2k',
                        '3MB', etc) [default: 20 MB]
  --chunk CHUNK         size of file download chunk (can use '1024', '2k',
                        '3MB', etc) [default: 20 MB]
  -e, --verify          Verify upload / download [default : False]
  -f, --force-hash      force file MD5 / CRC32 calculation instead of using
                        cached value
  --resume-download RESUMEDL
                        resume instead of restarting when downloading if local
                        file already exists [default: True]
  --include-regex INCREGEX
                        regular expression of files to include. if not
                        specified (default), everything is included. for
                        download, the regex applies to the remote files; for
                        upload, the regex applies to the local files. to
                        exclude files, think about your regex, some tips here:
                        https://stackoverflow.com/questions/406230/regular-
                        expression-to-match-string-not-containing-a-word
                        [default: ]
  --on-dup ONDUP        what to do when the same file / folder exists in the
                        destination: 'overwrite', 'skip', 'prompt' [default:

  --no-symlink          DON'T follow symbol links when uploading / syncing up
  --disable-ssl-check   DON'T verify host SSL cerificate
  --cacerts CACERTS     Specify the path for CA Bundle [default: None]
  --mirror MIRROR       Specify the PCS mirror (e.g. bj.baidupcs.com. Open 'ht
                        tps://pcs.baidu.com/rest/2.0/pcs/manage?method=listhos
                        t' to get the list) to use. [default: pcs.baidu.com]
  --rapid-upload-only   only upload large files that can be rapidly uploaded
  -c, --clean           1: clean settings (remove the token file) 2: clean
                        settings and hash cache [default: 0]


Commands:
help <command> - provide some information for the command
cdl_add <source_url> [save_path] [timeout] - add an offline (cloud) download task
cdl_addmon <source_url> [save_path] [timeout] - add an offline (cloud) download task and monitor the download progress
cdl_cancel <task_id>  - cancel an offline (cloud) download task
cdl_list - list offline (cloud) download tasks
cdl_query <task_ids>  - query existing offline (cloud) download tasks
cleancache - remove invalid entries from hash cache file
combine <remotefile> [localfile] [md5s] - try to create a file at PCS by combining slices, having MD5s specified
compare [remotedir] [localdir] - compare the remote direcotry with the local directory
copy/cp <from> <to> - copy a file / dir remotely at Baidu Yun
delete/remove/rm <remotepath> - delete a file / dir remotely at Baidu Yun
downdir <remotedir> [localdir] - download a remote directory (recursively)
downfile <remotefile> [localpath] - download a remote file.
dumpcache - display file hash cache
list/ls [remotepath] [format] [sort] [order] - list the 'remotepath' directory at Baidu PCS
listrecycle [start] [limit] - list the recycle contents
meta <remotepath> [format] - get information of the given path (dir / file) at Baidu Yun.
mkdir <remotedir> - create a directory at Baidu Yun
move/mv/rename/ren <from> <to> - move a file / dir remotely at Baidu Yun
quota/info - displays the quota information
refreshtoken - refresh the access token
restore <remotepath> - restore a file from the recycle bin
search <keyword> [remotepath] [recursive] - search for a file using keyword at Baidu Yun
stream <remotefile> <localpipe> [format] [chunk] - stream a video / audio file converted to M3U format at cloud side, to a pipe.
syncdown [remotedir] [localdir] [deletelocal] - sync down from the remote direcotry to the local directory
syncup [localdir] [remotedir] [deleteremote] - sync up from the local direcotry to the remote directory
upload [localpath] [remotepath] [ondup] - upload a file or directory (recursively)

公众微信:idc5ahl
公众QQ:吾爱互联
关注公众微信,公众QQ每天领现金卡密
卡密介绍(http://www.5ahl.com/thread-2182-1-1.html
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 点我注册

快速回复 返回顶部 返回列表