<commit_before>import requests
from hmac import HMAC
from datetime import datetime
#from hashlib import md5, sha512
import logging
import ConfigParser

config = ConfigParser.SafeConfigParser()
config.read('victims-db-builder.cfg')
hostname = config.get('victims_api', 'hostname')
port = config.get('victims_api', 'port')
protocol = config.get('victims_api', 'protocol')
server = "{0}://{1}:{2}".format(protocol, hostname, port)



def uploadArchive(username, password, filename, gid, aid, vid, cves):
    logger.info("uploading file: " + filename)
    server = "%s://%s:%s" % (protocol, hostname, port)
    path = "/service/v2/submit/archive/java/?version=%s\&groupId=%s\&artifactId=%s\&cves=%s" % (
        vid, gid, aid, ','.join(cves))
    url = server + path
    #date = datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
    with open(filename, 'rb') as archive:
        #md5sums = [md5(archive.read()).hexdigest()]
        #archive.seek(0)
        files = { 'archive': archive }
        response = requests.put(url,
            #headers = {'X-Victims-Api': "%s:%s" % (apiKey, generate_signature(
            #	secret, 'PUT', path, date, md5sums)),
            #	"Date": date},
            files=files,
            auth = (username, password)
            )
    logger.info(response.text)

logger = logging.getLogger(__name__)<commit_msg>added support for coord only upload<commit_after>import requests
from hmac import HMAC
from datetime import datetime
#from hashlib import md5, sha512
import logging
import ConfigParser

config = ConfigParser.SafeConfigParser()
config.read('victims-db-builder.cfg')
hostname = config.get('victims_api', 'hostname')
port = config.get('victims_api', 'port')
protocol = config.get('victims_api', 'protocol')
server = "{0}://{1}:{2}".format(protocol, hostname, port)

def uploadArchive(username, password, filename, gid, aid, vid, cves):
    logger.info("uploading file: %s" % filename)
    path = "/service/v2/submit/archive/java/?version=%s\&groupId=%s\&artifactId=%s\&cves=%s" % (
        vid, gid, aid, ','.join(cves))
    url = server + path
    #date = datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
    if filename is not None:
	with open(filename, 'rb') as archive:
            #md5sums = [md5(archive.read()).hexdigest()]
            #archive.seek(0)
            files = { 'archive': archive }
            response = requests.put(url,
                #headers = {'X-Victims-Api': "%s:%s" % (apiKey, generate_signature(
                #	secret, 'PUT', path, date, md5sums)),
                #	"Date": date},
                files=files,
                auth = (username, password)
                )
        logger.info(response.text)
    else:
	response = requests.put(url,
	    auth = (username, password)
	    )
	logger.info(response.text)

logger = logging.getLogger(__name__)
{'fraction_non_alphanumeric': 0.16308559351884466, 'fraction_numerical': 0.008453680873547023, 'mean_word_length': 3.176470588235294, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '216449', 'n_tokens_mistral': 945, 'n_tokens_neox': 912, 'n_words': 210}