Esempio n. 1
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!"
Esempio n. 2
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!"
Esempio n. 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")
Esempio n. 4
0
def test_put():
    scsbox = SCSBox("store.bav.baidu.com", 8080)
    scsbox.put_file("/home/pengchong/src/ws/server/sample_cloud_sdk/scs/A02EEEB7601FEDD4EE6323A02087919B",
                    {"hash" : "A02EEEB7601FEDD4EE6323A02087919B",
                     "hashtype" : 1,
                     "source" : "0",
                     "FileName" : "",
                     "FilePath" : ""
                     },
                     "wcollecter",
                     "bavwc1234asdf")
Esempio n. 5
0
def test_put3():
    scsbox = SCSBox()
    scsbox.put_file(
        "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/C27E59D45E9FD16626E8FEF4684F10EB",
        {
            "hash": "C27E59D45E9FD16626E8FEF4684F10EB",
            "hashtype": 1,
            "source": "101",
            "FileName": "helloworld.txt",
            "FilePath": "/home/xuzeshui/src/bav-cloud/bcs_sample/scs"
        }, "wcollecter", "bavwc1234asdf")
Esempio n. 6
0
def test_put2():
    scsbox = SCSBox()
    scsbox.put_file("/home/xuzeshui/src/bav-cloud/bcs_sample/scs/FF0D8FD026C1DF74D12E2F1FC40992EF",
                    {"hash" : "FF0D8FD026C1DF74D12E2F1FC40992EF",
                     "hashtype" : 1,
                     "source" : "101",
                     "FileName" : "helloworld.txt",
                     "FilePath" : "/home/xuzeshui/src/bav-cloud/bcs_sample/scs"
                     },
                     "wcollecter",
                     "bavwc1234asdf")
Esempio n. 7
0
def test_put():
    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")
Esempio n. 8
0
def test_put2():
    scsbox = SCSBox()
    scsbox.put_file(
        "/home/xuzeshui/src/bav-cloud/bcs_sample/scs/FF0D8FD026C1DF74D12E2F1FC40992EF",
        {
            "hash": "FF0D8FD026C1DF74D12E2F1FC40992EF",
            "hashtype": 1,
            "source": "101",
            "FileName": "helloworld.txt",
            "FilePath": "/home/xuzeshui/src/bav-cloud/bcs_sample/scs"
        }, "wcollecter", "bavwc1234asdf")
Esempio n. 9
0
def test_put():
    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")
Esempio n. 10
0
def test_put3():
    scsbox = SCSBox()
    scsbox.put_file("/home/xuzeshui/src/bav-cloud/bcs_sample/scs/C27E59D45E9FD16626E8FEF4684F10EB",
                    {"hash" : "C27E59D45E9FD16626E8FEF4684F10EB",
                     "hashtype" : 1,
                     "source" : "101",
                     "FileName" : "helloworld.txt",
                     "FilePath" : "/home/xuzeshui/src/bav-cloud/bcs_sample/scs"
                     },
                     "wcollecter",
                     "bavwc1234asdf")
Esempio n. 11
0
def test_put():
    scsbox = SCSBox("store.bav.baidu.com", 8080)
    scsbox.put_file(
        "/home/pengchong/src/ws/server/sample_cloud_sdk/scs/A02EEEB7601FEDD4EE6323A02087919B",
        {
            "hash": "A02EEEB7601FEDD4EE6323A02087919B",
            "hashtype": 1,
            "source": "0",
            "FileName": "",
            "FilePath": ""
        }, "wcollecter", "bavwc1234asdf")
Esempio n. 12
0
def test_stat():
    scsbox = SCSBox("store.bav.baidu.com", 8080, "clientupload", "bavcup2135sadghkj")

    for md5 in open("md5_list", "r"):
        md5_name = md5.strip()
        try:
            print scsbox.stat_file(md5_name)
            print "%s fin" % md5_name
        except Exception, e:
            print "%s------> not ok" % md5_name
            print str(e)
Esempio n. 13
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)
Esempio n. 14
0
def test_stat():
    scsbox = SCSBox("store.bav.baidu.com", 8080, "clientupload",
                    "bavcup2135sadghkj")

    for md5 in open("md5_list", "r"):
        md5_name = md5.strip()
        try:
            print scsbox.stat_file(md5_name)
            print "%s fin" % md5_name
        except Exception, e:
            print "%s------> not ok" % md5_name
            print str(e)
Esempio n. 15
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)
Esempio n. 16
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 ""
Esempio n. 17
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 ""
Esempio n. 18
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"
    )
Esempio n. 19
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!"
Esempio n. 20
0
 def login(self):
     self.scsbox = SCSBox("store.bav.baidu.com", 80, "bcollecter",
                          "bavbc1234qwer")
Esempio n. 21
0
def test_sample_existed():
    scsbox = SCSBox("store.bav.baidu.com", 8080)
    print scsbox.check_sample_existed("00000072E6E3C20F4D10F68DEEFA6BFB")
    print scsbox.check_sample_existed("00000000000000000000000000000000")
Esempio n. 22
0
def test_sample_existed():
    scsbox = SCSBox("clientupload", "bavcup2135sadghkj")
    print scsbox.check_sample_existed("54D88381B61A3B2EB28942663A98410A")
    print scsbox.check_sample_existed("00000000000000000000000000000000")
    print scsbox.check_sample_existed("0d595d6bfb471b28acb4ddd8f65b54d1")
Esempio n. 23
0
def test_stat():
    scsbox = SCSBox("clientupload", "bavcup2135sadghkj")
    #scsbox = SCSBox("hk01-sd-sample-cache00.hk01.baidu.com", 8080, "clientupload", "bavcup2135sadghkj")
    tableindex = int("54D88381B61A3B2EB28942663A98410A".__hash__()) % 16
    print "tableindex", tableindex
    print scsbox.stat_file("54D88381B61A3B2EB28942663A98410A")
Esempio n. 24
0
def test_sample_existed():
    scsbox = SCSBox("store.bav.baidu.com", 8080)
    print scsbox.check_sample_existed("00000072E6E3C20F4D10F68DEEFA6BFB")
    print scsbox.check_sample_existed("00000000000000000000000000000000")
Esempio n. 25
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!"
Esempio n. 26
0
def test_sample_existed():
    scsbox = SCSBox("clientupload", "bavcup2135sadghkj")
    print scsbox.check_sample_existed("54D88381B61A3B2EB28942663A98410A")
    print scsbox.check_sample_existed("00000000000000000000000000000000")
    print scsbox.check_sample_existed("0d595d6bfb471b28acb4ddd8f65b54d1")
Esempio n. 27
0
 def login(self):
     self.scsbox = SCSBox("store.bav.baidu.com", 80, "bcollecter", "bavbc1234qwer")
Esempio n. 28
0
def test_stat():
    scsbox = SCSBox("clientupload", "bavcup2135sadghkj")
    #scsbox = SCSBox("hk01-sd-sample-cache00.hk01.baidu.com", 8080, "clientupload", "bavcup2135sadghkj")
    tableindex = int("54D88381B61A3B2EB28942663A98410A".__hash__()) % 16
    print "tableindex", tableindex
    print scsbox.stat_file("54D88381B61A3B2EB28942663A98410A")