diff options
| author | Navan Chauhan <navanchauhan@gmail.com> | 2020-07-07 12:40:28 +0530 | 
|---|---|---|
| committer | Navan Chauhan <navanchauhan@gmail.com> | 2020-07-07 12:40:28 +0530 | 
| commit | 3b6482cb0ab7eb51756213ccf7b7c8822fbda3d5 (patch) | |
| tree | c3b3f6e35cb86e9c1998a8e969c1db77233fe309 /tests/backendTest.py | |
| parent | bb730182584b09233ae955db41385864f087a4cb (diff) | |
Fixed 10 Anti-Pattern issues
Diffstat (limited to 'tests/backendTest.py')
| -rw-r--r-- | tests/backendTest.py | 19 | 
1 files changed, 8 insertions, 11 deletions
| diff --git a/tests/backendTest.py b/tests/backendTest.py index 7db0d8c..33b6019 100644 --- a/tests/backendTest.py +++ b/tests/backendTest.py @@ -27,9 +27,9 @@ def email(compressedFile):      msg.attach(MIMEText(body, 'plain'))       filename = "Curie_Web_Results_Job_ID_" + str(jobID) + ".zip" -    attachment = open((str(compressedFile) + ".zip"), "rb")       p = MIMEBase('application', 'octet-stream')  -    p.set_payload((attachment).read())  +    with open((str(zi) + ".zip"), "rb") as attachment: +        p.set_payload((attachment).read())       encoders.encode_base64(p)       p.add_header('Content-Disposition', "attachment; filename= %s" % filename)       msg.attach(p)  @@ -79,15 +79,12 @@ from shutil import make_archive  with tempfile.TemporaryDirectory() as directory:      print('The created temporary directory is %s' % directory)      os.chdir(directory) -    file = open(receptor_name,"wb") -    file.write(targetB) -    file.close() -    file = open(ligand_name,"wb") -    file.write(ligandB) -    file.close() -    file = open("config.txt","wb") -    file.write(configB) -    file.close() +    with open(receptor_name,"wb") as file: +        file.write(targetB) +    with open(ligand_name,"wb") as file: +        file.write(ligandB) +    with open("config.txt","wb") as file: +        file.write(configB)      os.system("docker run --rm -v ${PWD}:/results -w /results -u $(id -u ${USER}):$(id -g ${USER}) navanchauhan/curie-cli -r %s -l %s  -c config.txt -dpi" % (receptor_name,ligand_name))      z = "Curie_Web_Result_"+str(jobID)      zi = os.path.join(f,z) | 
