예제 #1
0
def test_all():
    scsbox = SCSBox()
    scsbox.put_file(
        "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/54D88381B61A3B2EB28942663A98410A",
        {
            "hash": "54D88381B61A3B2EB28942663A98410A",
            "hashtype": 1,
            "source": "201",
            "FileName": "helloworld.txt",
            "FilePath": "/home/xuzeshui/src/bav-cloud/bcs_sample/scs"
        }, "wcollecter", "bavwc1234asdf")
    print scsbox.stat_file("54D88381B61A3B2EB28942663A98410A")
    print scsbox.stat_file("00000000000000000000000000000000")
    if scsbox.check_sample_existed("54D88381B61A3B2EB28942663A98410A"):
        print "put succeeded"
    if scsbox.check_sample_existed(
            "00000000000000000000000000000000") == False:
        print "it is right!"
    if scsbox.get_to_file(
            "54D88381B61A3B2EB28942663A98410A",
            "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/hello.txt"):
        print "succeeded to get file"
    if scsbox.get_to_file(
            "00000000000000000000000000000000",
            "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/hello000.txt"
    ) == False:
        print "it is right!"
예제 #2
0
def test_all():
    scsbox = SCSBox("store.bav.baidu.com", 8080)
    scsbox.put_file("/home/pengchong/src/ws/server/sample_cloud_sdk/scs/00000072E6E3C20F4D10F68DEEFA6BFB",
                    {"hash" : "00000072E6E3C20F4D10F68DEEFA6BFB",
                      "hashtype" : 1,
                     "source" : "101",
                     "FileName" : "sample.exe",
                     "FilePath" : "c:\sample.exe"
                     })
    print scsbox.stat_file("00000072E6E3C20F4D10F68DEEFA6BFB")
    print scsbox.stat_file("00000000000000000000000000000000")
    if scsbox.check_sample_existed("00000072E6E3C20F4D10F68DEEFA6BFB"):
        print "put succeeded"
    if scsbox.check_sample_existed("00000000000000000000000000000000") == False:
        print "it is right!"
    if scsbox.get_to_file("00000072E6E3C20F4D10F68DEEFA6BFB",
                       "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/local_sample"):
        print "succeeded to get file"
    if scsbox.get_to_file("00000000000000000000000000000000",
                       "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/local_sample_000") == False:
        print "it is right!"

    status = scsbox.put_file("/home/pengchong/src/ws/server/sample_cloud_sdk/scs/00000072E6E3C20F4D10F68DEEFA6BFB",
                    {"hash" : "00000072E6E3C20F4D10F68DEEFA6BFB",
                      "hashtype" : 1,
                     "source" : "101",
                     "FileName" : "sample.exe",
                     "FilePath" : "c:\sample.exe"
                     })
    if status == 2:
        print "it is right!"
예제 #3
0
def test_get():
    scsbox = SCSBox("clientupload", "bavcup2135sadghkj")
    #scsbox = SCSBox("hk01-sd-sample-cache00.hk01.baidu.com", 8000, "clientupload", "bavcup2135sadghkj")
    #scsbox = SCSBox("127.0.0.1", 8080, "clientupload", "bavcup2135sadghkj")
    #print scsbox.get_to_file("94A0F196A28B3FC9FF3E25BCF0D61A51",
    #                   "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/helloworld.txt", instant_mode=False)
    print scsbox.get_to_file("54D88381B61A3B2EB28942663A98410A", "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/54D88381B61A3B2EB28942663A98410A")
    print scsbox.get_to_file("99C6FF852A115420CA6D2BF26BBF071D", "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/99C6FF852A115420CA6D2BF26BBF071D")
    print scsbox.get_to_file("14D88381B61A3B2EB28942663A98410A", "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/14D88381B61A3B2EB28942663A98410A")
예제 #4
0
def test_get():
    scsbox = SCSBox("store.bav.baidu.com", 8080, "clientupload", "bavcup2135sadghkj")

    for md5 in open("md5_list_existed", "r"):
        md5_name = md5.strip()
        try:
            scsbox.get_to_file(md5_name,
                               "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/vault/%s" % md5_name)
            print "%s fin" % md5_name
        except Exception, e:
            print "%s------> not ok" % md5_name
            print str(e)
예제 #5
0
def test_get():
    scsbox = SCSBox("store.bav.baidu.com", 8080, "clientupload",
                    "bavcup2135sadghkj")

    for md5 in open("md5_list_existed", "r"):
        md5_name = md5.strip()
        try:
            scsbox.get_to_file(
                md5_name,
                "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/vault/%s" %
                md5_name)
            print "%s fin" % md5_name
        except Exception, e:
            print "%s------> not ok" % md5_name
            print str(e)
예제 #6
0
class clsGetSample(object):
    
    def __init__(self, sfile, sdown):
        self.filepath = sfile
        self.downpath = sdown
        self.login()
        
    def login(self):
        self.scsbox = SCSBox("store.bav.baidu.com", 80, "bcollecter", "bavbc1234qwer")
        
    def filestat(self, md5):
        #dict = self.scsbox.stat_file(md5)
        #print dict["file_size"]
        #return dict["existed"]
        return True
        
    def getfile(self, md5):
        savepath = os.path.join(self.downpath, md5)
        if self.filestat(md5):
            if self.scsbox.get_to_file(md5, savepath):
                logger.debug("%s-->下载成功." % md5)
            else:
                logger.info("%s-->下载失败." % md5)
        else:
            logger.info("%s-->文件不存在." % md5)

    def DownSample(self):
        f = open(self.filepath, "r")
        data = f.read()
        f.close()
    
        md5lst = data.split("\n")
        nCnt = len(md5lst)
        print "一共%d个文件." % nCnt
        index = 0
        for md5 in md5lst:
            md5 = md5.strip()
            if 32 != len(md5):
                continue
            nTry = 0
            index += 1
            print "%d/%d. MD5:%s" % (index, nCnt, md5)
            while True:
                try:
                    self.getfile(md5)
                    break
                except Exception, e:
                    #print e        #出错信息
                    nTry += 1
                    print "%s:下载出错,重试第%d次." % (md5, nTry)
                    #os.system('pause')
                    #self.login()
                    if 3 == nTry:
                        logger.info("%s-->下载发生错误." % md5)
                        break
            print ""
예제 #7
0
class clsGetSample(object):
    def __init__(self, sfile, sdown):
        self.filepath = sfile
        self.downpath = sdown
        self.login()

    def login(self):
        self.scsbox = SCSBox("store.bav.baidu.com", 80, "bcollecter",
                             "bavbc1234qwer")

    def filestat(self, md5):
        #dict = self.scsbox.stat_file(md5)
        #print dict["file_size"]
        #return dict["existed"]
        return True

    def getfile(self, md5):
        savepath = os.path.join(self.downpath, md5)
        if self.filestat(md5):
            if self.scsbox.get_to_file(md5, savepath):
                logger.debug("%s-->下载成功." % md5)
            else:
                logger.info("%s-->下载失败." % md5)
        else:
            logger.info("%s-->文件不存在." % md5)

    def DownSample(self):
        f = open(self.filepath, "r")
        data = f.read()
        f.close()

        md5lst = data.split("\n")
        nCnt = len(md5lst)
        print "一共%d个文件." % nCnt
        index = 0
        for md5 in md5lst:
            md5 = md5.strip()
            if 32 != len(md5):
                continue
            nTry = 0
            index += 1
            print "%d/%d. MD5:%s" % (index, nCnt, md5)
            while True:
                try:
                    self.getfile(md5)
                    break
                except Exception, e:
                    #print e        #出错信息
                    nTry += 1
                    print "%s:下载出错,重试第%d次." % (md5, nTry)
                    #os.system('pause')
                    #self.login()
                    if 3 == nTry:
                        logger.info("%s-->下载发生错误." % md5)
                        break
            print ""
예제 #8
0
def test_all():
    scsbox = SCSBox("store.bav.baidu.com", 8080)
    scsbox.put_file(
        "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/00000072E6E3C20F4D10F68DEEFA6BFB",
        {
            "hash": "00000072E6E3C20F4D10F68DEEFA6BFB",
            "hashtype": 1,
            "source": "101",
            "FileName": "sample.exe",
            "FilePath": "c:\sample.exe"
        })
    print scsbox.stat_file("00000072E6E3C20F4D10F68DEEFA6BFB")
    print scsbox.stat_file("00000000000000000000000000000000")
    if scsbox.check_sample_existed("00000072E6E3C20F4D10F68DEEFA6BFB"):
        print "put succeeded"
    if scsbox.check_sample_existed(
            "00000000000000000000000000000000") == False:
        print "it is right!"
    if scsbox.get_to_file(
            "00000072E6E3C20F4D10F68DEEFA6BFB",
            "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/local_sample"):
        print "succeeded to get file"
    if scsbox.get_to_file(
            "00000000000000000000000000000000",
            "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/local_sample_000"
    ) == False:
        print "it is right!"

    status = scsbox.put_file(
        "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/00000072E6E3C20F4D10F68DEEFA6BFB",
        {
            "hash": "00000072E6E3C20F4D10F68DEEFA6BFB",
            "hashtype": 1,
            "source": "101",
            "FileName": "sample.exe",
            "FilePath": "c:\sample.exe"
        })
    if status == 2:
        print "it is right!"
예제 #9
0
def test_all():
    scsbox = SCSBox()
    scsbox.put_file("/home/xuzeshui/src/bav-cloud/bcs_sample/scs/54D88381B61A3B2EB28942663A98410A",
                    {"hash" : "54D88381B61A3B2EB28942663A98410A",
                     "hashtype" : 1,
                     "source" : "201",
                     "FileName" : "helloworld.txt",
                     "FilePath" : "/home/xuzeshui/src/bav-cloud/bcs_sample/scs"
                     },
                     "wcollecter",
                     "bavwc1234asdf")
    print scsbox.stat_file("54D88381B61A3B2EB28942663A98410A")
    print scsbox.stat_file("00000000000000000000000000000000")
    if scsbox.check_sample_existed("54D88381B61A3B2EB28942663A98410A"):
        print "put succeeded"
    if scsbox.check_sample_existed("00000000000000000000000000000000") == False:
        print "it is right!"
    if scsbox.get_to_file("54D88381B61A3B2EB28942663A98410A",
                       "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/hello.txt"):
        print "succeeded to get file"
    if scsbox.get_to_file("00000000000000000000000000000000",
                       "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/hello000.txt") == False:
        print "it is right!"
예제 #10
0
def test_get():
    scsbox = SCSBox("clientupload", "bavcup2135sadghkj")
    #scsbox = SCSBox("hk01-sd-sample-cache00.hk01.baidu.com", 8000, "clientupload", "bavcup2135sadghkj")
    #scsbox = SCSBox("127.0.0.1", 8080, "clientupload", "bavcup2135sadghkj")
    #print scsbox.get_to_file("94A0F196A28B3FC9FF3E25BCF0D61A51",
    #                   "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/helloworld.txt", instant_mode=False)
    print scsbox.get_to_file(
        "54D88381B61A3B2EB28942663A98410A",
        "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/54D88381B61A3B2EB28942663A98410A"
    )
    print scsbox.get_to_file(
        "99C6FF852A115420CA6D2BF26BBF071D",
        "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/99C6FF852A115420CA6D2BF26BBF071D"
    )
    print scsbox.get_to_file(
        "14D88381B61A3B2EB28942663A98410A",
        "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/14D88381B61A3B2EB28942663A98410A"
    )