<commit_before>#!/usr/bin/env python
###############################################################################
 #  Copyright (c) 2015 <NAME>
 #  Project: 
 #  Filename: uploader.py 
 #  Version: 1.0
 #  Author: <NAME>
 #  E-mail: <EMAIL>
 #  Date: Aug  3, 2015
 #  Time: 13:29:39
 #  Description: 
###############################################################################


import tencentyun

class Uploader(object):
    def __init__(self, appid, bucket, secret_id, secret_key):
        self.appid = appid
        self.bucket = bucket
        self.secret_id = secret_id
        self.secret_key = secret_key
        self.image_obj = tencentyun.ImageV2(self.appid, self.secret_id, self.secret_key)

    def upload_filename(self, filename, fileid):
        response_obj = self.image_obj.upload(filename, self.bucket, fileid)

        if "code" not in response_obj or response_obj["code"] != 0:
            print(fileid, response_obj)
        
        # upload success
        if "code" in response_obj and response_obj["code"] == 0:
            return 0
        # upload failed
        return 1

    def upload_binary(self, binary, fileid):
        response_obj = self.image_obj.upload_binary(binary, self.bucket, fileid)

        if "code" in response_obj and response_obj["code"] == 0:
            return 0
        return 1<commit_msg>add debug info<commit_after>#!/usr/bin/env python
###############################################################################
 #  Copyright (c) 2015 <NAME>
 #  Project: 
 #  Filename: uploader.py 
 #  Version: 1.0
 #  Author: <NAME>
 #  E-mail: <EMAIL>
 #  Date: Aug  3, 2015
 #  Time: 13:29:39
 #  Description: 
###############################################################################


from __future__ import print_function
import tencentyun

class Uploader(object):
    def __init__(self, appid, bucket, secret_id, secret_key):
        self.appid = appid
        self.bucket = bucket
        self.secret_id = secret_id
        self.secret_key = secret_key
        self.image_obj = tencentyun.ImageV2(self.appid, self.secret_id, self.secret_key)

    def upload_filename(self, filename, fileid):
        response_obj = self.image_obj.upload(filename, self.bucket, fileid)

        if "code" not in response_obj or response_obj["code"] != 0:
            print(fileid, response_obj)
        
        # upload success
        if "code" in response_obj and response_obj["code"] == 0:
            return 0
        # upload failed
        return 1

    def upload_binary(self, binary, fileid):
        response_obj = self.image_obj.upload_binary(binary, self.bucket, fileid)

        if "code" not in response_obj or response_obj["code"] != 0:
            print(fileid, response_obj)

        if "code" in response_obj and response_obj["code"] == 0:
            return 0
        return 1
{'fraction_non_alphanumeric': 0.2035211267605634, 'fraction_numerical': 0.01795774647887324, 'mean_word_length': 2.984572230014025, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4971186', 'n_tokens_mistral': 894, 'n_tokens_neox': 825, 'n_words': 207}