<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
See the Chimera Programmer's FAQ, question #3, <a
href="http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html#q3">http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html#q3</a>,
for how to write a shell script wrapper around a chimera script to
hide the fact that chimera is running the script instead of python
and use getopt everywhere.<br>
<br>
-- Greg<br>
<br>
On 03/15/2011 02:12 PM, Eric Pettersen wrote:
<blockquote
cite="mid:C63E1834-BE8D-4642-8FD4-24F4247B3B27@cgl.ucsf.edu"
type="cite">
<div>
<div>On Mar 15, 2011, at 5:37 AM, wascm wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">Dear sir:<br>
<br>
Thanks for the detailed reply!<br>
<br>
When the following code was added to the start of sciprt:<br>
<br>
<i>import chimeraInit<br>
chimeraInit.init(nogui=True, silent=True)</i><br>
<br>
The interpreter print the following confused error: <br>
<br>
---------------------------------------------<br>
<i>Traceback (most recent call last):<br>
File "./xx.py", line 5, in <module><br>
chimeraInit.init(nogui=True, silent=True)<br>
TypeError: init() takes at least 1 argument (2 given)</i><br>
</blockquote>
<div><br>
</div>
There was an oversight in the code Greg provided:
chimeraInit.init takes a mandatory "argv" argument, which is
exactly like sys.argv.</div>
<div><br>
<blockquote type="cite">-----------------------------------------------<br>
<br>
it's really easy and convenient to running python script with
chimera. The reason for i want to run python script
independently is that i want add some custom command option.
However, if i run python script with chimera, it's hard for me
to add some custom command option and handle it in the script
though getopt module.<br>
<br>
For example, when i run some command like this:<br>
<br>
chimera –nogui test.py -t test<br>
<br>
test.py<br>
################### <br>
#!/usr/bin/python<br>
<br>
t=None<br>
<br>
try:<br>
opts, args = getopt.getopt(sys.argv[1:], "t:")<br>
except getopt.GetoptError, err: <br>
pass<br>
finally: <br>
for arg_k, arg_v in opts:<br>
if (arg_k =="-t"): t=arg_v<br>
####################################<br>
<br>
This will raise running exception!<br>
<br>
is there a way for me to add the coustom option to python
script and run the script with chimera?</blockquote>
<br>
</div>
<div>Yes. Use a --script argument, like this:</div>
<div><br>
</div>
<div>chimera --nogui --script "test.py -t test"</div>
<div><br>
</div>
<div>--Eric</div>
<div><br>
</div>
<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Chimera-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Chimera-dev@cgl.ucsf.edu">Chimera-dev@cgl.ucsf.edu</a>
<a class="moz-txt-link-freetext" href="http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev">http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>