Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
guppy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Svetlana Tkachenko
guppy
Commits
61ac8056
Commit
61ac8056
authored
13 years ago
by
Svetlana Tkachenko
Browse files
Options
Downloads
Patches
Plain Diff
attempt to add dns, rpn plugins
parent
bfb1fc06
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/dns.py
+24
-0
24 additions, 0 deletions
plugins/dns.py
plugins/rpn.py
+42
-0
42 additions, 0 deletions
plugins/rpn.py
with
66 additions
and
0 deletions
plugins/dns.py
0 → 100644
+
24
−
0
View file @
61ac8056
# dns module
# --gry
import
urllib
import
socket
@plugin
class
dns
(
object
):
def
__init__
(
self
,
server
):
self
.
server
=
server
self
.
commands
=
[
"
dns
"
]
self
.
server
.
handle
(
"
command
"
,
self
.
handle_command
,
self
.
commands
)
def
handle_command
(
self
,
channel
,
user
,
cmd
,
args
):
if
cmd
==
"
dns
"
:
if
len
(
args
)
<
1
:
self
.
server
.
doMessage
(
channel
,
user
+
"
: Return a fully qualified domain name for a list of space-separated IPs or hostnames.
"
)
return
try
:
for
each
in
args
:
self
.
server
.
doMessage
(
channel
,
user
+
"
:
"
+
each
+
"
=
"
+
socket
.
getfqdn
(
each
))
except
Exception
,
e
:
self
.
server
.
doMessage
(
channel
,
user
+
"
:
"
+
str
(
e
))
This diff is collapsed.
Click to expand it.
plugins/rpn.py
0 → 100644
+
42
−
0
View file @
61ac8056
# rpn module
# --gry
@plugin
class
rpn
(
object
):
def
__init__
(
self
,
server
):
self
.
server
=
server
self
.
commands
=
[
"
rpn
"
]
self
.
server
.
handle
(
"
command
"
,
self
.
handle_command
,
self
.
commands
)
def
handle_command
(
self
,
channel
,
user
,
cmd
,
args
):
if
cmd
==
"
rpn
"
:
if
len
(
args
)
<
1
:
self
.
server
.
doMessage
(
channel
,
user
+
"
: reverse-polish-notation calculator. syntax: rpn 2 4 1 + / gives 2/5.
"
)
return
self
.
stack
=
[]
for
char
in
args
:
try
:
char
=
float
(
char
)
# if it succeeds, then char is a number
self
.
stack
.
append
(
char
)
except
Exception
,
e
:
#float(char) failed, it's nonsense or an operator
try
:
a
=
float
(
self
.
stack
.
pop
())
#last
b
=
float
(
self
.
stack
.
pop
())
#pre-last
if
(
char
==
"
+
"
):
self
.
stack
.
append
(
a
+
b
)
elif
(
char
==
"
-
"
):
self
.
stack
.
append
(
b
-
a
)
elif
(
char
==
"
^
"
):
self
.
stack
.
append
(
pow
(
b
,
a
))
elif
(
char
==
"
*
"
):
self
.
stack
.
append
(
a
*
b
)
elif
(
char
==
"
/
"
):
self
.
stack
.
append
(
b
/
a
)
except
Exception
,
e
:
self
.
conn
.
reply
(
str
(
e
))
return
try
:
self
.
server
.
doMessage
(
channel
,
user
+
"
:
"
+
str
(
self
.
stack
[
0
]))
except
Exception
,
e
:
return
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment