<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Bypy on Wanzi&#39;s Blog – Notes on life, tech, and DevOps.</title>
    <link>https://wanzi.dev/tags/bypy/</link>
    <description>Recent content in Bypy on Wanzi&#39;s Blog – Notes on life, tech, and DevOps.</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <managingEditor>wzdushu@gmail.com (wanzi)</managingEditor>
    <webMaster>wzdushu@gmail.com (wanzi)</webMaster>
    <copyright>丸子有记</copyright>
    <lastBuildDate>Mon, 04 Dec 2023 16:22:42 +0800</lastBuildDate>
    
        <atom:link href="https://wanzi.dev/tags/bypy/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>A Powerful Tool for Operating Baidu Cloud on Linux</title>
      <link>https://wanzi.dev/post/tools-bypy-baiduyunpan/</link>
      <pubDate>Mon, 04 Dec 2023 16:22:42 +0800</pubDate>
      <author>wzdushu@gmail.com (wanzi)</author>
      <guid>https://wanzi.dev/post/tools-bypy-baiduyunpan/</guid>
      
        <description>&lt;p&gt;Recently, I was performing a private deployment of our company&amp;rsquo;s SAAS product at the customer site. Since the customer&amp;rsquo;s network cannot access the internet, data can only be transferred through a Linux jump server. In addition to the k8s offline deployment program and images, there are also several hundred GB of pre-cut video data, which can only be transferred via Baidu Netdisk. I wondered if it was possible to synchronize Baidu Netdisk data via the command line. A quick Google search revealed that it is indeed possible. Below, I will briefly introduce the use of bypy.&lt;/p&gt;
&lt;h2 id=&#34;introduction-to-bypy&#34;&gt;Introduction to bypy&lt;/h2&gt;
&lt;p&gt;bypy is a Python client for Baidu Cloud/Baidu Netdisk, mainly used for operating Baidu Netdisk under Linux. It provides functionalities such as file listing, downloading, uploading, comparison, upsync, and downsync. Key features include support for Unicode/Chinese, retry on failure, recursive upload/download, directory comparison, and hash caching.&lt;/p&gt;
&lt;p&gt;Due to Baidu PCS API permission restrictions, the program can only access files and directories under the /apps/bypy directory in Baidu Cloud.&lt;/p&gt;
&lt;h2 id=&#34;installing-bypy&#34;&gt;Installing bypy&lt;/h2&gt;
&lt;p&gt;Install pip&lt;/p&gt;
&lt;div class=&#34;highlight-container&#34;&gt;

  &lt;button class=&#34;copy-code-btn outline&#34;&gt;Copy&lt;/button&gt;

  
  &lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
curl -O https://bootstrap.pypa.io/pip/3.6/get-pip.py
python get-pip.py &lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Install bypy&lt;/p&gt;
&lt;div class=&#34;highlight-container&#34;&gt;

  &lt;button class=&#34;copy-code-btn outline&#34;&gt;Copy&lt;/button&gt;

  
  &lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;pip install bypy&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&#34;highlight-container&#34;&gt;

  &lt;button class=&#34;copy-code-btn outline&#34;&gt;Copy&lt;/button&gt;

  
  &lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;python -m bypy info # Generate an authorization code, then open a browser to authorize and enter the authorization code&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Copy and paste the authorization code into the terminal, press Enter, and you&amp;rsquo;re done.&lt;/p&gt;
&lt;h2 id=&#34;detailed-bypy-commands&#34;&gt;Detailed bypy Commands&lt;/h2&gt;
&lt;div class=&#34;highlight-container&#34;&gt;

  &lt;button class=&#34;copy-code-btn outline&#34;&gt;Copy&lt;/button&gt;

  
  &lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ bypy help command # View command help
$ bypy info  # View Baidu Netdisk space
Quota: 13.294TB
Used: 1.917TB
$ bypy list # View &amp;#34;My Application Data&amp;#34; in Baidu Netdisk
/apps/bypy ($t $f $s $m $d):
D course 0 2023-12-04, 15:21:41
D k8s 0 2023-12-04, 15:47:47

$ bypy downdir k8s # Directly download the k8s directory under bypy
$ bypy syncup # Sync the current directory to the cloud
$ bypy upload # Sync the current directory to the cloud
$ bypy syncdown # Sync the cloud content to the current directory
$ bypy downdir / # Sync the cloud content to the current directory

$ bypy compare # Compare the local current directory with the root directory of the cloud (program)
$ bypy -v # Adding the -v parameter during runtime will display progress details.
$ bypy -d # Adding -d during runtime will display some debug information
$ bypy -ddd # Display more HTTP communication information&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;This concludes my exploration of using bypy. During my research, I found many tools based on baidupcs, but most of these projects are no longer maintained. I hope bypy can continue to be supported.&lt;/p&gt;
&lt;p&gt;Reference: &lt;a href=&#34;https://github.com/houtianze/bypy&#34;&gt;https://github.com/houtianze/bypy&lt;/a&gt;&lt;/p&gt;
</description>
      
    </item>
    
  </channel>
</rss>
