# Path: multiscanner/common/utils.py
# def basename(path):
#     """OS independent version of os.path.basename"""
#     if path.endswith('/') or path.endswith('\\'):
#         path = path[:-1]
#     split = path.split('/')
#     if len(split) > 1:
#         return split[-1]
#     else:
#         split = path.split('\\')
#         return split[-1]


import requests
import time
from multiscanner.common.utils import basename
    '''
    fetch_delay_seconds = conf['fetch delay seconds']
    poll_interval_seconds = conf['poll interval seconds']
    api_key = conf['API key']
    if api_key.strip() == '':
        api_key = None

    resultlist = []
    tasks = []
    if conf['API URL'].endswith('/'):
        url = conf['API URL']
    else:
        url = conf['API URL'] + '/'
    scan_url = url + 'metascan_rest/file'
    results_url = url + 'metascan_rest/file/'

    user_agent = conf['user agent']
    for fname in filelist:
        submission_resp = _submit_sample(fname, scan_url, user_agent, api_key)
        resp_status_code = submission_resp['status_code']
        if resp_status_code == requests.codes.ok:
            task_id = submission_resp['scan_id']
            if task_id is not None:
                tasks.append((fname, str(task_id)))
            else:
                # TODO Do something here?
                pass
        else:
            err_msg = submission_resp['error']
            print('%s: %s not submitted: Code: %d, Message: %s'

# Path: multiscanner/common/utils.py
# def basename(path):
#     """OS independent version of os.path.basename"""
#     if path.endswith('/') or path.endswith('\\'):
#         path = path[:-1]
#     split = path.split('/')
#     if len(split) > 1:
#         return split[-1]
#     else:
#         split = path.split('\\')
#         return split[-1]


# Path: multiscanner/modules/Antivirus/Metadefender.py
import requests
import time
from multiscanner.common.utils import basename

    '''
    fetch_delay_seconds = conf['fetch delay seconds']
    poll_interval_seconds = conf['poll interval seconds']
    api_key = conf['API key']
    if api_key.strip() == '':
        api_key = None

    resultlist = []
    tasks = []
    if conf['API URL'].endswith('/'):
        url = conf['API URL']
    else:
        url = conf['API URL'] + '/'
    scan_url = url + 'metascan_rest/file'
    results_url = url + 'metascan_rest/file/'

    user_agent = conf['user agent']
    for fname in filelist:
        submission_resp = _submit_sample(fname, scan_url, user_agent, api_key)
        resp_status_code = submission_resp['status_code']
        if resp_status_code == requests.codes.ok:
            task_id = submission_resp['scan_id']
            if task_id is not None:
                tasks.append((fname, str(task_id)))
            else:
                # TODO Do something here?
                pass
        else:
            err_msg = submission_resp['error']
            print('%s: %s not submitted: Code: %d, Message: %s'

                  % (NAME, basename(fname), resp_status_code, err_msg))