print 'Beginning keytest.py'
+FNULL = open('/dev/null', 'w')
+
DELAY = '59'
class CommandSource:
drop = random.randint(0, len(self.lines) - 1)
del self.lines[drop]
- p = p - 1 / len(self.lines)
+ #p = p - 1 / len(self.lines)
origlines = self.lines
self.lines = []
for l in origlines:
os._exit(0)
if self.i >= len(self.lines):
self.loops = self.loops + 1
+ if self.loops > 3:
+ os._exit(0)
self.i = 0
return 'Loop'
line = self.lines[self.i]
self.count = self.count + 1
self.i = self.i + 1
- print 'Line read: <<' + line + '>>\n'
+ #print 'Line read: <<' + line + '>>\n'
+ sys.stdout.write('r')
return line.rstrip('\n').rstrip()
before_secs = time.time()
while not lyx_sleeping():
time.sleep(0.02)
- print '.',
+ sys.stdout.write('.')
if time.time() - before_secs > 180:
print 'Killing due to freeze (KILL_FREEZE)'
while not lyx_sleeping():
time.sleep(0.02)
print '.',
- print 'Making Screenshot: ' + screenshot_out
+ print 'Making Screenshot: ' + screenshot_out + ' OF ' + infilename
time.sleep(0.2)
os.system('import -window root '+screenshot_out+str(x.count)+".png")
time.sleep(0.1)
sys.stdout.flush()
- subprocess.call(["xvkbd", "-xsendevent", "-delay", DELAY, "-text", keystr])
+ if (subprocess.call(
+ ["xvkbd", "-xsendevent", "-delay", DELAY, "-text", keystr],
+ stdout=FNULL,stderr=FNULL
+ ) == 0):
+ sys.stdout.write('*')
+ else:
+ sys.stdout.write('X')
+
+def system_retry(num_retry, cmd):
+ i = 0
+ rtn = os.system(cmd)
+ while ( ( i < num_retry ) and ( rtn != 0) ):
+ i = i + 1
+ rtn=os.system(cmd)
+ time.sleep(1)
+ if ( rtn != 0 ):
+ print "Command Failed: "+cmd
+ print " EXITING!\n"
+ os._exit(1)
def RaiseWindow():
os.system("echo x-session-manager PID: $X_PID.")
os.system("echo x-session-manager open files: `lsof -p $X_PID | grep ICE-unix | wc -l`")
- os.system("wmctrl -l | ( grep '"+lyx_window_name+"' || ( killall lyx ; sleep 1 ; killall -9 lyx ))")
- os.system("wmctrl -R '"+lyx_window_name+"' ;sleep 0.1")
+ ####os.system("wmctrl -l | ( grep '"+lyx_window_name+"' || ( killall lyx ; sleep 1 ; killall -9 lyx ))")
+ #os.system("wmctrl -R '"+lyx_window_name+"' ;sleep 0.1")
+ system_retry(30, "wmctrl -R '"+lyx_window_name+"'")
lyx_pid = os.environ.get('LYX_PID')
write_commands = True
while True:
- os.system('echo -n LOADAVG:; cat /proc/loadavg')
+ #os.system('echo -n LOADAVG:; cat /proc/loadavg')
c = x.getCommand()
if c == 'Loop':
outfile.close()
if os.path.exists('/proc/' + lyx_pid + '/status'):
sendKeystring(c[4:], lyx_pid)
else:
- os.system('killall lyx; sleep 2 ; killall -9 lyx')
+ ##os.system('killall lyx; sleep 2 ; killall -9 lyx')
print 'No path /proc/' + lyx_pid + '/status, exiting'
os._exit(1)
elif c[0:4] == 'KD: ':