Example #1
0
File: test.py Project: fcl-a/bypy
def main():
	testmergeinto()
	prepare()
	time.sleep(2)
	testshare()
	time.sleep(2)
	# sleep sometime helps preventing hanging requests <scorn>
	cdl()
	time.sleep(2)
	emptyremote()
	time.sleep(2)
	time.sleep(2)
	uploaddir()
	time.sleep(2)
	getquota()
	time.sleep(2)
	compare()
	time.sleep(2)
	downdir()
	time.sleep(2)
	syncup()
	time.sleep(2)
	syncdown()

	# test aria2 downloading
	global by
	by = bypy.ByPy(configdir=configdir, downloader='aria2', debug=1, verbose=1)
	downdir()

	# clean up
	os.remove(zerofilename)
	shutil.rmtree(configdir, ignore_errors=True)
	shutil.rmtree(sharedir, ignore_errors=True)
	shutil.rmtree(downloaddir, ignore_errors=True)
Example #2
0
 def __init__(self, localPath, remotePath, syncTime, syncFlag):
     super(syncThread, self).__init__()
     #关键参数,由主线程告诉同步线程
     self.localPath = localPath  #本地目录
     self.remotePath = remotePath  #远程目录
     self.syncTime = syncTime  #自动同步时间
     self.syncFlag = syncFlag
     self.mybp = bypy.ByPy()  #是否同步的标志位
     self.exitflg = 1  #退出线程标志位,0时退出线程
Example #3
0
 def initUI(self):
     # 设置托盘图标
     self.tp.setIcon(QIcon(res_dir + 'cloud.ico'))
     #初始化bypy
     self.mybp = bypy.ByPy()
     infomsg = self.mybp.info()
     print(infomsg)
     #检查本地与远程目录正确性
     self.syncFlag = 1  #启用同步,如果是0则是不启用同步
     if not os.path.exists(self.cfgw.localPath):
         QMessageBox.question(self.cfgw, "提示", "不存在本地文件夹,请设置本地同步目录")
         self.syncFlag = 0
         self.cfgw.show()
     if self.mybp.meta(self.cfgw.remotePath) != 0:
         QMessageBox.question(self.cfgw, "提示",
                              "不存在远程文件夹,请在百度云盘中的bypy文件夹里,建立linux文件夹")
         self.syncFlag = 0
     #连接信号槽
     self.cfgw.pushButton_movedir.clicked.connect(self.on_moveLocalPath)
Example #4
0
import bypy
import configparser as config
import os

#读取配置文件
cfg = config.ConfigParser()
cfg.read("src/config.ini")
localPath = cfg.get("SET", "localPath")
remotePath = cfg.get("SET", "remotePath")
syncTime = int(cfg.get("SET", "syncTime"))
print("读取配置文件\n本地:" + localPath + "\n远程:" + remotePath)
print("同步时间:", syncTime)

bp = bypy.ByPy()
bp1 = bypy.ByPy()
#bp.info()
#bp.list()
fc = bp.meta("linux/fgv/sdd")
print("fc:", fc)
fc = bp1.meta("linux/fgv/")
print("fc:", fc)

print("########################")
x = bp.syncup(localPath, remotePath, True)
print("x:", type(x), x)
bp.list()
#bp.syncdown(remotePath,localPath,True)
#bp.syncup(localPath,remotePath,True)
#bp.compare(remotePath,localPath)
Example #5
0
bypydir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#sys.path.insert(0, bypydir)
sys.path.append(bypydir)
#print(sys.path)
configdir = 'configdir'
downloaddir = 'downdir'
testdir = 'testdir'
import bypy
# monkey patch all the way
mpr = StorePrinter(bypy.pr)
bypy.pr = mpr.pr
# create some dummy files
zerofilename = os.path.join(testdir, 'allzero.1m.bin')
makesuredir(configdir)
shutil.copy('bypy.json', configdir)
by = bypy.ByPy(configdir=configdir, debug=1, verbose=1)


def testmergeinto():
    fromc = {'a': {'a1': 1, 'a2': 2}, 'b': {'b1': 10, 'b2': 20}}

    to = {
        'a': {
            'a1': 9,
            'a3': 3
        },
        'b': {
            'b2': 90,
            'b3': 30,
        },
        'c': {
Example #6
0
#coding=utf-8

import bypy
by = bypy.ByPy(configdir="test", debug=1, verbose=1)

by.upload("test" + '/a.txt')