[Chimera-users] save reply log from chimera python script

Thomas Goddard goddard at cgl.ucsf.edu
Mon Oct 13 10:49:43 PDT 2008


Hi Katryna,

   The original code defines a function.  You leave it unchanged and add 
a line at the end to call it as follows.

	Tom

def save_reply_log(path):
   from chimera import dialogs
   r = dialogs.find('reply')
   text = r.text.get('1.0', 'end')
   f = open(path, 'w')
   f.write(text)
   f.close()

save_reply_log("/tmp/tmplog.txt")


Katryna Cisek wrote:
> Hi Chimera Users,
> Could someone please point out the syntax error in this code:
> 
> def save_reply_log("/tmp/tmplog.txt"):    <<--- error should be here
> based on error info
>     from chimera import dialogs
>     r = dialogs.find('reply')
>     text = r.text.get('1.0', 'end')
>     f = open('/tmp/tmplog.txt', 'w')
>     f.write(text)
>     f.close()
> 
> ---------------------------chimera error info from reply
> log-------------------------------
> 
> <type 'exceptions.SyntaxError'> Exception in Tk callback
>   Function: <function command at 0x132d230> (type: <type 'function'>)
>   Args: ()
> Traceback (innermost last):
>   File "CHIMERA/lib/python2.5/site-packages/Pmw/Pmw_1_3/lib/PmwBase.py",
> line 1747, in __call__
>     None
>   File "CHIMERA/share/chimera/baseDialog.py", line 244, in command
>     None
>   File "CHIMERA/share/chimera/baseDialog.py", line 453, in OK
>     None
>   File "CHIMERA/share/OpenSave/__init__.py", line 161, in Apply
>     None
>   File "CHIMERA/share/SimpleSession/gui.py", line 41, in _openCB
>     None
>   File "CHIMERA/share/chimera/__init__.py", line 1344, in open
>     None
>   File "CHIMERA/share/chimera/__init__.py", line 787, in _openPython
>     None
> <type 'exceptions.SyntaxError'>: invalid syntax
> (refalignrotatewholesymmetrysavelog.py, line 58)
> 
> --------------
> 
> Thanks,
> Katryna
> 
> 
> On Wed, Oct 8, 2008 at 10:33 PM, Tom Goddard <goddard at cgl.ucsf.edu> wrote:
>> Hi Katryna,
>>
>>  I don't think there is a command to save the text in the reply log.  In the
>> Python function the variable path is the path to the file, for example
>> "/tmp/mylog.txt".
>>
>>   Tom
>>
>>
>> Katryna Cisek wrote:
>>> Hi Chimera users,
>>> Is there a new way to save the reply log from a chimera python script,
>>> other than below (from Chimera Archive 2006)?
>>>
>>> def save_reply_log(path):
>>>  from chimera import dialogs
>>>  r = dialogs.find('reply')
>>>  text = r.text.get('1.0', 'end')
>>>  f = open(path, 'w')
>>>  f.write(text)
>>>  f.close()
>>>
>>> If not, what is the filename given to the reply log in this function?
>>> Is it possible to
>>> designate the name?
>>> Thanks,
>>> Katryna
>>> _______________________________________________
>>> Chimera-users mailing list
>>> Chimera-users at cgl.ucsf.edu
>>> http://www.cgl.ucsf.edu/mailman/listinfo/chimera-users
>>>
>>




More information about the Chimera-users mailing list