Brief description:
- Due to Baidu PCS API permission restrictions, bypy can only access the files and directories under Baidu cloud / apps/bypy directory
- bypy doesn't speed up. If you want to download without speed limit, you need to buy SVIP yourself
Lao Su wrote before Running Baidu network disk client in Docker That's the official client with a graphical interface, and bypy is a third-party command-line tool
Build mirror
If you don't want to build it yourself, you can skip and read the next chapter directly
bypy doesn't officially provide Dockerfile or image, but there are still many third-party ones, but they are old, so Lao Su is still going to build them himself
- Dockerfile v1
FROM python:3.6-slim MAINTAINER laosu<wbsu2003@gmail.com> WORKDIR /baidupy COPY . /baidupy/ # Environment ENV TERM=xterm RUN pip install bypy # Application EXPOSE 80 ENV NAME Python_client_for_Baidu_Yun CMD bypy info
However, Lao Su found that the v1 container could not be started after it was stopped, because bypy info would exit after obtaining the cloud disk capacity, resulting in exited with code 0. Therefore, Lao Su introduced a Supervisor for process management
- Dockerfile v2
FROM python:3.6-slim MAINTAINER laosu<wbsu2003@gmail.com> WORKDIR /baidupy # Application RUN apt-get update -y && \ apt-get install -y supervisor RUN pip install bypy # supervisord COPY supervisord.conf /etc/supervisord.conf # Environment ENV TERM=xterm ENV NAME=Python_client_for_Baidu_Yun #Define time zone parameters (not required) ENV TZ=Asia/Shanghai #Set time zone (not required) RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone #Set code (not required) ENV LANG C.UTF-8 ENTRYPOINT ["supervisord","-c","/etc/supervisord.conf"]
In addition to Dockerfile, the v2 version also needs to prepare the supervisor.conf file
[include] files = /etc/supervisor/conf.d/*.conf [program:bypy] command=bypy info #directory will be any folder where you wnat supervisor to cd before executing. #directory=/project autostart=true autorestart=false startretries=3 #user will be anyone you want but make sure that user will have the enough privilage. user=root [supervisord] nodaemon=true logfile=/tmp/supervisord.log pidfile=/tmp/supervisord.pid loglevel=debug logfile_maxbytes=10MB [supervisorctl]
The basic commands for building images and running containers are as follows 👇
# Put Dockerfile and supervisor.conf in the same directory # Build mirror docker build -t wbsu2003/bypy:v2 . # Build container docker run -it --name=bypy \ -v /volume2/docker/bypy:/baidupy \ wbsu2003/bypy:v2 # Run container docker start bypy # Enter container docker exec --user root -it bypy /bin/sh # Exit container exit perhaps ctrl+D
install
Install in Docker mode on Qunhui.
Search wbsu2003 in the registry, find wbsu2003/bypy, and select latest.
volume
In the docker folder, create a new folder and name it bypy
folder | Load path | explain |
---|---|---|
docker/bypy | /baidupy | File storage directory |
function
Like cloud189 cli, bypy is also in the command line mode, so it can be run either on the SSH client or on the "terminal".
Lao Su suggested that it is more convenient to run on the SSH client. For cloud189 cli, please see: Use Tianyi cloud disk on Qunhui』
Terminal -- > New -- > Start -- > bash through command
The first time you need authorization, execute bypy info, then copy the contents of the red box and open it in the browser
Copy the generated authorization code
Paste into the red box and press enter
The program will use different servers for authentication. Successful authentication will display the capacity of Baidu network disk. If it fails at one time, you can try several times.
The process is a little long, and the probability of failure is quite high. Be patient~~~
Some websites report errors directly
Some cannot be accessed
In extreme cases, the authentication will fail. You can only do it again because the authorization code has a time limit
After successful authentication, the size of the space will be displayed
Authorization only needs one time. Once successful, there will be no authorization prompt in the future
access_token and refresh_token are saved in / ~ /. bypy/bypy.json
Common commands
help
Execute bypy or bypy help
More detailed can be run
bypy help <command>
For example: bypy help list
File list
Execute bypy list to list the files of the cloud disk
In / apps/bypy directory on Baidu disk
download
That is, synchronize the cloud disk content locally. You can execute bypy syncdown or bypy downdir /. If you are not a member, the download speed is slow
After downloading, you can see the downloaded file in the File Station
upload
That is, synchronize the current directory to the cloud disk. You can execute bypy syncup or bypy upload
First, add a nearly 100 megabyte exe file in the File Station
Uploading is a little faster than downloading
Synchronization complete
Refresh network disk
compare
To compare the current local directory with the root directory of the cloud disk (program), execute bypy compare
Why is it Different:2. Lao Su didn't understand. It's probably because the download was interrupted
For more commands and detailed explanations, see the output of running bypy, or read the official documentation.
Reference documents
houtianze/bypy: Python client for Baidu Yun (Personal Cloud Storage) Baidu cloud / Baidu network disk Python client
Address: https://github.com/houtianze/bypy/
bypy - Baidu network disk Python client linux - simple book
Address: https://www.jianshu.com/p/c9467daf701f/
exited with code 0 docker - Stack Overflow
Address: https://stackoverflow.com/questions/44884719/exited-with-code-0-docker
Understanding Docker Container Exit Codes | by Sandeep Madamanchi | Better Programming
Address: https://betterprogramming.pub/understanding-docker-container-exit-codes-5ee79a1d58f6