<commit_before>from deepviz import sandbox

sbx = sandbox.Sandbox()

result = sbx.sample_result(md5="00000000000000000000000000000000",
                           apikey="0000000000000000000000000000000000000000000000000000000000000000")
f = open("result.txt", "wb")
f.write(str(result))
f.close()

result = sbx.sample_report(md5="00000000000000000000000000000000",
                           apikey="0000000000000000000000000000000000000000000000000000000000000000")
f = open("report.txt", "wb")
f.write(str(result))
f.close()

result = sbx.download_sample(md5="00000000000000000000000000000000",
                             apikey="0000000000000000000000000000000000000000000000000000000000000000", path=".")<commit_msg>updated with upload-and-wait-result example code<commit_after>from deepviz import sandbox
import time
import hashlib

sbx = sandbox.Sandbox()

# Retrieve sample scan result
result = sbx.sample_result(md5="00000000000000000000000000000000",
                           api_key="0000000000000000000000000000000000000000000000000000000000000000")
f = open("result.txt", "wb")
f.write(str(result))
f.close()

# Retrieve sample full scan report
result = sbx.sample_report(md5="00000000000000000000000000000000",
                           api_key="0000000000000000000000000000000000000000000000000000000000000000")
f = open("report.txt", "wb")
f.write(str(result))
f.close()

# Download sample binary
result = sbx.download_sample(md5="00000000000000000000000000000000",
                             api_key="0000000000000000000000000000000000000000000000000000000000000000",
                             path=".")

# Upload a sample and wait until the analysis is complete
_hash = hashlib.md5(open("file.exe", 'rb').read()).hexdigest()

sbx.upload_sample(path="file.exe", api_key="0000000000000000000000000000000000000000000000000000000000000000")
result = sbx.sample_result(md5=_hash, api_key="0000000000000000000000000000000000000000000000000000000000000000")

while result.status != "success":
    time.sleep(30)
    result = sbx.sample_result(md5=_hash, api_key="0000000000000000000000000000000000000000000000000000000000000000")

print result.msg['classification']['result']
{'fraction_non_alphanumeric': 0.10473588342440801, 'fraction_numerical': 0.35473588342440804, 'mean_word_length': 4.953929539295393, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 15, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7452782', 'n_tokens_mistral': 1241, 'n_tokens_neox': 491, 'n_words': 98}