Hugo Garcia-Cotte commited on
Commit
dfaa337
1 Parent(s): 61ecf8c

banging my head on Streamlit

Browse files
Files changed (1) hide show
  1. app.py +40 -36
app.py CHANGED
@@ -24,40 +24,42 @@ while True:
24
  st.write(msg)
25
 
26
  st.session_state['messages'].append("Tick.")
27
- line = child.readline()
28
- st.session_state['messages'].append(line)
29
- if ">>>>>" in line:
 
 
 
 
 
30
  user_input = st.text_input("Enter your message here:")
31
- if user_input : child.sendline(user_input)
32
-
33
-
34
-
35
-
36
- """
37
- last_line = child.readline()
38
-
39
- st.session_state['messages'].append(last_line)
40
-
41
- # Display the list of messages
42
- for msg in st.session_state['messages']:
43
- st.write(msg)
44
-
45
- if ">>>>>" in last_line:
46
- # Create a text input field for users to enter their messages
47
- user_input = st.text_input("Enter your message here:")
48
-
49
- # Add user's message to the list when the submit button is clicked
50
- if user_input:
51
- st.session_state['messages'].append(user_input)
52
- child.sendline(user_input)
 
 
53
 
54
  """
55
 
56
-
57
-
58
-
59
-
60
- """
61
  import pexpect
62
  import time
63
 
@@ -66,9 +68,11 @@ child = pexpect.spawn("python DO_NOT_COMMIT.py", encoding='utf-8', timeout=None)
66
 
67
  while True:
68
  time.sleep(1)
69
- print("Tick.")
70
- line = child.readline()
71
- print(line)
72
- if ">>>>>" in line: child.sendline(input(">>>>>"))
73
-
74
- """
 
 
 
24
  st.write(msg)
25
 
26
  st.session_state['messages'].append("Tick.")
27
+ line = None
28
+ try :
29
+ line = child.read_nonblocking(size=1000, timeout=0)
30
+ except:
31
+ pass
32
+ if line is not None: st.session_state['messages'].append(line)
33
+
34
+ if ">>>>>" in st.session_state['messages'][-1]:
35
  user_input = st.text_input("Enter your message here:")
36
+ if user_input :
37
+ st.session_state['messages'].append(user_input)
38
+ child.sendline(user_input)
39
+
40
+
41
+
42
+
43
+ #
44
+ # last_line = child.readline()
45
+ #
46
+ # st.session_state['messages'].append(last_line)
47
+ #
48
+ # # Display the list of messages
49
+ # for msg in st.session_state['messages']:
50
+ # st.write(msg)
51
+ #
52
+ # if ">>>>>" in last_line:
53
+ # # Create a text input field for users to enter their messages
54
+ # user_input = st.text_input("Enter your message here:")
55
+ #
56
+ # # Add user's message to the list when the submit button is clicked
57
+ # if user_input:
58
+ # st.session_state['messages'].append(user_input)
59
+ # child.sendline(user_input)
60
 
61
  """
62
 
 
 
 
 
 
63
  import pexpect
64
  import time
65
 
 
68
 
69
  while True:
70
  time.sleep(1)
71
+ line = None
72
+ try :
73
+ line = child.read_nonblocking(size=1000, timeout=0)
74
+ except:
75
+ pass
76
+ if line is not None: print(repr(line))
77
+ #if ">>>>>" in line: child.sendline(input(">>>>>"))
78
+ """