-
Notifications
You must be signed in to change notification settings - Fork 0
/
IP_address.py
77 lines (68 loc) · 2.34 KB
/
IP_address.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- coding: utf-8 -*-
#
# Representation of an IP address
#
from Node import *
from locator import Base
if Base != object.__class__:
from sqlalchemy import Column, Integer, String
class IP_address(Node, Base):
if Base != object.__class__:
__tablename__ = 'ipaddr'
ident = Column(String, primary_key=True)
name = Column(String)
ip = Column(String)
x = Column(Integer)
y = Column(Integer)
read_features = ["ip"]
features = []
tiny_pixbuf = gtk.gdk.pixbuf_new_from_xpm_data([
"26 20 5 1",
" c black",
". c grey",
"o c yellow",
"X c blue",
"- c None",
"--------------------------",
"--------------------------",
"- ----- ---",
"- ----- ------ --",
"- ----- -------- -",
"- ----- -------- -",
"- ----- -------- -",
"- ----- -------- -",
"- ----- -------- -",
"- ----- ------- -",
"- ----- ---",
"- ----- ------------",
"- ----- ------------",
"- ----- ------------",
"- ----- ------------",
"- ----- ------------",
"- ----- ------------",
"- ----- ------------",
"- ----- ------------",
"--------------------------",
"--------------------------",
])
def __init__(self, name=None, ip="192.168.0.2", x=50, y=50, ident=None, gui=None):
assert(ip != None)
self.ip = ip
Node.__init__(self, name, 'IP', x, y, ident, gui)
def getIp(self):
return self.ip
def setIp(self, ip):
assert(ip != None)
self.ip = ip
# this doesn't have to find neighbors
def node_clicked(self, widget, event):
# If right-click
if event.button == 3:
if not self.gui.node_connected_with_class(self, "Host") and not self.gui.node_connected_with_class(self, "DNS_server"):
newmenu = gtk.Menu()
item_remove = gtk.MenuItem('Remove')
newmenu.append(item_remove)
item_remove.connect("button-press-event", self.disappear)
newmenu.show_all()
newmenu.popup(None, None, None, event.button, event.time)
# vim: set et sts=4 sw=4: