2 # Highly Optimized Object-oriented Many-particle Dynamics -- Blue Edition
3 # (HOOMD-blue) Open Source Software License Copyright 2008-2011 Ames Laboratory
4 # Iowa State University and The Regents of the University of Michigan All rights
7 # HOOMD-blue may contain modifications ("Contributions") provided, and to which
8 # copyright is held, by various Contributors who have granted The Regents of the
9 # University of Michigan the right to modify and/or distribute such Contributions.
11 # You may redistribute, use, and create derivate works of HOOMD-blue, in source
12 # and binary forms, provided you abide by the following conditions:
14 # * Redistributions of source code must retain the above copyright notice, this
15 # list of conditions, and the following disclaimer both in the code and
16 # prominently in any materials provided with the distribution.
18 # * Redistributions in binary form must reproduce the above copyright notice, this
19 # list of conditions, and the following disclaimer in the documentation and/or
20 # other materials provided with the distribution.
22 # * All publications and presentations based on HOOMD-blue, including any reports
23 # or published results obtained, in whole or in part, with HOOMD-blue, will
24 # acknowledge its use according to the terms posted at the time of submission on:
25 # http://codeblue.umich.edu/hoomd-blue/citations.html
27 # * Any electronic documents citing HOOMD-Blue will link to the HOOMD-Blue website:
28 # http://codeblue.umich.edu/hoomd-blue/
30 # * Apart from the above required attributions, neither the name of the copyright
31 # holder nor the names of HOOMD-blue's contributors may be used to endorse or
32 # promote products derived from this software without specific prior written
37 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND
38 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
39 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR ANY
40 # WARRANTIES THAT THIS SOFTWARE IS FREE OF INFRINGEMENT ARE DISCLAIMED.
42 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
43 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
45 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
46 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
47 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
48 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51 # Maintainer: joaander
58 from hoomd_script
import globals;
61 # \package hoomd_script.util
62 # \brief Internal utility functions used by hoomd_script
65 # \brief Internal flag tracking if
66 _disable_status_lines
= False;
68 ## Prints a status line tracking the execution of the current hoomd script
69 def print_status_line():
70 if _disable_status_lines
:
73 # get the traceback info first
74 stack
= traceback
.extract_stack();
76 globals.msg
.notice(2, "hoomd_script executing unknown command\n");
77 file_name
, line
, module
, code
= stack
[-3];
79 # if we are in interactive mode, there is no need to print anything: the
80 # interpreter loop does it for us. We can make that check by testing if
81 # sys.ps1 is defined (this is not a hack, the python documentation states
82 # that ps1 is _only_ defined in interactive mode
83 if 'ps1' in sys
.__dict
__:
86 # piped input from stdin doesn't provide a code line, handle the situation
88 message
= os
.path
.basename(file_name
) + ":" + str(line
).zfill(3) + " | <unknown code>";
89 globals.msg
.notice(1, message
+ '\n');
91 # build and print the message line
92 # Go upwards in the source until you match the closing paren
93 # dequote ensures we ignore literal parens
94 dequote
= lambda x
: re
.sub(r
'[\'"].*?[\'"]','',x)
95 balance = lambda y: y.count('(') - y.count(')')
98 message.insert(0,linecache.getline(file_name,line))
99 if sum(balance(dequote(x)) for x in message) == 0 or line == 0:
103 message.insert(0,os.path.basename(file_name) + ":" + str(line).zfill(3) + " | ")
104 globals.msg.notice(1, ''.join(message).rstrip('\n') + '\n');
105 linecache.clearcache()