mirror of
https://github.com/ail-project/ail-framework.git
synced 2025-01-31 22:46:15 +00:00
Added end of paste marker + handling screen resize
This commit is contained in:
parent
444f6071b7
commit
0254c51164
1 changed files with 40 additions and 14 deletions
|
@ -382,7 +382,7 @@ class Show_paste(Frame):
|
||||||
self.add_layout(layout)
|
self.add_layout(layout)
|
||||||
|
|
||||||
self.label_list = []
|
self.label_list = []
|
||||||
self.num_label = 41
|
self.num_label = 42
|
||||||
for i in range(self.num_label):
|
for i in range(self.num_label):
|
||||||
self.label_list += [Label("THE PASTE CONTENT " + str(i))]
|
self.label_list += [Label("THE PASTE CONTENT " + str(i))]
|
||||||
layout.add_widget(self.label_list[i])
|
layout.add_widget(self.label_list[i])
|
||||||
|
@ -417,6 +417,8 @@ class Show_paste(Frame):
|
||||||
for i, c in enumerate(old_content):
|
for i, c in enumerate(old_content):
|
||||||
if ord(c) > 127:
|
if ord(c) > 127:
|
||||||
content += '?'
|
content += '?'
|
||||||
|
elif c == "\t":
|
||||||
|
content += " "
|
||||||
else:
|
else:
|
||||||
content += c
|
content += c
|
||||||
|
|
||||||
|
@ -424,11 +426,18 @@ class Show_paste(Frame):
|
||||||
to_print = ""
|
to_print = ""
|
||||||
i = 0
|
i = 0
|
||||||
for line in content.split("\n"):
|
for line in content.split("\n"):
|
||||||
if i==self.num_label:
|
if i > self.num_label - 2:
|
||||||
break
|
break
|
||||||
self.label_list[i]._text = str(i) + ". " + line.replace("\r","")
|
self.label_list[i]._text = str(i) + ". " + line.replace("\r","")
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
if i > self.num_label - 2:
|
||||||
|
self.label_list[i]._text = "..."
|
||||||
|
i += 1
|
||||||
|
else:
|
||||||
|
self.label_list[i]._text = "- END -"
|
||||||
|
i += 1
|
||||||
|
|
||||||
while i<self.num_label:
|
while i<self.num_label:
|
||||||
self.label_list[i]._text = ""
|
self.label_list[i]._text = ""
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -463,6 +472,11 @@ def demo(screen):
|
||||||
time_cooldown = time.time()
|
time_cooldown = time.time()
|
||||||
global TABLES
|
global TABLES
|
||||||
while True:
|
while True:
|
||||||
|
#Stop on resize
|
||||||
|
if screen.has_resized():
|
||||||
|
screen._scenes[screen._scene_index].exit()
|
||||||
|
raise ResizeScreenError("Screen resized", screen._scenes[screen._scene_index])
|
||||||
|
|
||||||
if time.time() - time_cooldown > args.refresh:
|
if time.time() - time_cooldown > args.refresh:
|
||||||
cleanRedis()
|
cleanRedis()
|
||||||
for key, val in fetchQueueData().iteritems():
|
for key, val in fetchQueueData().iteritems():
|
||||||
|
@ -498,6 +512,7 @@ def cleanRedis():
|
||||||
for pid in server.smembers(k):
|
for pid in server.smembers(k):
|
||||||
flag_pid_valid = False
|
flag_pid_valid = False
|
||||||
proc = Popen([command_search_name.format(pid)], stdin=PIPE, stdout=PIPE, bufsize=1, shell=True)
|
proc = Popen([command_search_name.format(pid)], stdin=PIPE, stdout=PIPE, bufsize=1, shell=True)
|
||||||
|
try:
|
||||||
for line in proc.stdout:
|
for line in proc.stdout:
|
||||||
splittedLine = line.split()
|
splittedLine = line.split()
|
||||||
if ('python2' in splittedLine or 'python' in splittedLine) and "./"+moduleName+".py" in splittedLine:
|
if ('python2' in splittedLine or 'python' in splittedLine) and "./"+moduleName+".py" in splittedLine:
|
||||||
|
@ -511,6 +526,14 @@ def cleanRedis():
|
||||||
printarrayGlob.pop()
|
printarrayGlob.pop()
|
||||||
#time.sleep(5)
|
#time.sleep(5)
|
||||||
|
|
||||||
|
#Error due to resize, interrupted sys call
|
||||||
|
except IOError as e:
|
||||||
|
inst_time = datetime.datetime.fromtimestamp(int(time.time()))
|
||||||
|
printarrayGlob.insert(0, ([str(inst_time).split(' ')[1], " - ", " - ", "Cleaning fail due to resize."], 0))
|
||||||
|
printarrayGlob.pop()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def restart_module(module, count=1):
|
def restart_module(module, count=1):
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
p2 = Popen([command_restart_module.format(module, module)], stdin=PIPE, stdout=PIPE, bufsize=1, shell=True)
|
p2 = Popen([command_restart_module.format(module, module)], stdin=PIPE, stdout=PIPE, bufsize=1, shell=True)
|
||||||
|
@ -755,7 +778,10 @@ if __name__ == "__main__":
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
last_scene = None
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
Screen.wrapper(demo)
|
Screen.wrapper(demo)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
except ResizeScreenError as e:
|
||||||
|
pass
|
||||||
|
|
Loading…
Add table
Reference in a new issue