Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
d3de400b
Commit
d3de400b
authored
Feb 14, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added /raw command and better exception handling.
parent
b6fb2278
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
telematica/ass1/async.py
telematica/ass1/async.py
+10
-1
telematica/ass1/cli.py
telematica/ass1/cli.py
+13
-2
No files found.
telematica/ass1/async.py
View file @
d3de400b
...
...
@@ -41,6 +41,12 @@ class ClientConnection(object, asyncore.dispatcher):
self
.
port
=
addr
[
1
]
super
(
ClientConnection
,
self
).
connect
(
addr
)
def
send
(
self
,
cmd
):
"""
Send raw command to the chat server.
"""
self
.
send_queue
.
put
(
cmd
)
def
retrieve_users
(
self
):
"""
Retreive list of users active at the chat server.
...
...
@@ -57,7 +63,10 @@ class ClientConnection(object, asyncore.dispatcher):
self
.
send_queue
.
put
(
'USER %s'
%
name
)
def
handle_connect
(
self
):
"""Called when a connection is established."""
"""
Called when a connection is established.
"""
if
'connect'
in
self
.
event_list
:
self
.
event_list
[
'connect'
](
self
)
...
...
telematica/ass1/cli.py
View file @
d3de400b
...
...
@@ -196,7 +196,11 @@ All commands listed below should be preceded by a slash:
def
quit
(
main
):
# Disconnect the connection
del
self
.
connection
e
=
None
try
:
del
self
.
connection
except
:
pass
# Reverse the curses-friendly terminal settings.
curses
.
nocbreak
();
...
...
@@ -206,8 +210,14 @@ All commands listed below should be preceded by a slash:
# Restore the terminal to its original operating mode.
curses
.
endwin
()
if
e
:
raise
e
sys
.
exit
(
0
)
def
raw
(
main
,
cmd
):
main
.
connection
.
send
(
cmd
)
def
user
(
main
,
name
):
main
.
connection
.
username
(
name
)
...
...
@@ -223,6 +233,7 @@ All commands listed below should be preceded by a slash:
'exec'
:
_exec
,
'help'
:
help
,
'quit'
:
quit
,
'raw'
:
raw
,
'user'
:
user
,
}
...
...
@@ -274,7 +285,7 @@ All commands listed below should be preceded by a slash:
# Call command handler.
try
:
if
cmd
==
'exec'
:
if
cmd
==
'exec'
or
cmd
==
'raw'
:
cmd_fn
(
self
,
raw_command
)
else
:
cmd_fn
(
self
,
*
args
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment