Exemplo n.º 1
0
 def get_FrameType(prototype):
     try:
         return FRAME_TYPE[prototype]
     except:
         printWARN("extra_Ethernet<get_FrameType> not find " +
                   str(prototype))
         return str(prototype)
Exemplo n.º 2
0
def get_img(IP_list_tuple, myIP):

    IP_xy = []

    for IP_tuple in IP_list_tuple:
        for i in IP_tuple:
            if not i == myIP:
                XY = get_XY(ip=i)
                if not XY == None:
                    IP_xy.append(XY)
    printWARN("+" * 100)
    mp = smopy.Map(
        (min(IP_xy)[0], min(IP_xy)[1], max(IP_xy)[0], max(IP_xy)[1]), z=5)
    x = []
    y = []
    for xy in IP_xy:
        x1, y1 = mp.to_pixels(xy[0], xy[1])
        x.append(x1)
        y.append(y1)
    printWARN("*" * 100)
    mp.save_png("unit/curmap.png")
    plt.figure()
    ax = plt.subplot(111)
    plt.xticks([])
    plt.yticks([])
    plt.grid(False)
    plt.xlim(0, mp.w)
    plt.ylim(mp.h, 0)
    plt.axis('off')
    plt.tight_layout()
    ax.imshow(mp.img)
    ax.plot(x, y, 'or')
    plt.savefig("unit/plot.png")
Exemplo n.º 3
0
    def show_IP(self, IP_tuple):

        if str(self.myIP) in IP_tuple:
            self.IP_list_tuple.append(IP_tuple)
            printWARN("IP_tuple" + str(len(self.IP_list_tuple)))
            if len(self.IP_list_tuple) >= 100 and self.set_Png:
                self.set_Png == False
                # self.Thread_cap.stop()
                self.Image.setIP(self.IP_list_tuple[:100], self.myIP)
Exemplo n.º 4
0
 def get_type(self, itype, code):
     try:
         code_key = list(ICMPTYPE[str(itype)].keys())
         if code_key[0] == 'x':
             ''' random code '''
             return ICMPTYPE[str(itype)]['x']
         elif len(code_key) == 1 and code_key[0] == '0':
             return ICMPTYPE[str(itype)]['0']
         else:
             return ICMPTYPE[str(itype)][str(code)]
     except:
         printWARN('icmp key ERROR ', str(itype), str(code))
         return None
Exemplo n.º 5
0
 def print_result(self):
     if self.TYPEINFO == None:
         printWARN("ERROR")
     else:
         print('type: {}'.format(self.TYPEINFO.replace("_", " ")))
Exemplo n.º 6
0
 def restart(self):
     printWARN("START Thred")
     self.is_stop = False
Exemplo n.º 7
0
 def stop(self):
     printWARN("STOP Thred")
     self.is_stop = True