Python Forum
Problem Passing Arguement to do loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem Passing Arguement to do loop
#8
Had to make some changes to your changes:

#!/usr/bin/env python2.5
# -*- coding: utf-8 -*-
import subprocess
import sys
with open('ligands') as infile:
ligand = infile.read().strip().split()
for nvar in ligand:
command = [
"./pythonsh", "./prepare_ligand4.py",
"-l", nvar + ".mol2",
"-o", nvar + ".pbdqt" ]
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
out, err = proc.communicate()
print(out)
print(err)
if proc.returncode:
print ('Subprocess FAILED:', proc.command)

Here are the results:

runfile('/sdc1/Apps/Modeling/FileEditing/untitled1m2.py', wdir='/sdc1/Apps/Modeling/FileEditing')
Traceback (most recent call last):

File "/home/comp/Apps/miniconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "<ipython-input-1-51b00a34bbcd>", line 1, in <module>
runfile('/sdc1/Apps/Modeling/FileEditing/untitled1m2.py', wdir='/sdc1/Apps/Modeling/FileEditing')

File "/home/comp/Apps/miniconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 824, in runfile
execfile(filename, namespace)

File "/home/comp/Apps/miniconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "/sdc1/Apps/Modeling/FileEditing/untitled1m2.py", line 17
print 'Subprocess FAILED:', proc.command
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Subprocess FAILED:', proc.command)?




runfile('/sdc1/Apps/Modeling/FileEditing/untitled1m2.py', wdir='/sdc1/Apps/Modeling/FileEditing')
Traceback (most recent call last):

File "/home/comp/Apps/miniconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "<ipython-input-2-51b00a34bbcd>", line 1, in <module>
runfile('/sdc1/Apps/Modeling/FileEditing/untitled1m2.py', wdir='/sdc1/Apps/Modeling/FileEditing')

File "/home/comp/Apps/miniconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 824, in runfile
execfile(filename, namespace)

File "/home/comp/Apps/miniconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "/sdc1/Apps/Modeling/FileEditing/untitled1m2.py", line 12
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stdout=subprocess.PIPE)
^
SyntaxError: keyword argument repeated




runfile('/sdc1/Apps/Modeling/FileEditing/untitled1m2.py', wdir='/sdc1/Apps/Modeling/FileEditing')
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
b''
None
Reply


Messages In This Thread
RE: Problem Passing Arguement to do loop - by stephenmolnar - May-11-2019, 10:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem program runs in a loop jasserin 0 930 May-18-2024, 03:07 PM
Last Post: jasserin
  While Loop Problem Benno2805 1 1,312 Sep-06-2023, 04:51 PM
Last Post: deanhystad
  Loop reading csv file problem faustineaiden 1 2,297 Dec-11-2021, 08:40 AM
Last Post: ibreeden
  Infinite loop problem Zirconyl 5 4,423 Nov-16-2020, 09:06 AM
Last Post: DeaD_EyE
  Dataframe mean calculation problem: do we have to loop? sparkt 1 2,952 Aug-28-2020, 02:41 PM
Last Post: sparkt
  Python loop problem Kristenl2784 11 7,535 Jun-18-2020, 07:22 PM
Last Post: buran
  Problem with append list in loop michaelko03 0 2,278 Feb-16-2020, 07:04 PM
Last Post: michaelko03
  problem with for loop using integers python_germ 5 4,166 Aug-31-2019, 11:42 AM
Last Post: jefsummers
  problem in loop roseojha 3 3,119 Aug-26-2019, 09:03 AM
Last Post: perfringo
  Nested while loop problem + turtle DreamingInsanity 3 4,304 Jul-06-2019, 02:01 PM
Last Post: DreamingInsanity

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020