def __init__(self): super(Main, self).__init__() self.ui = MainWindow() self.ui.setupUi(self) self.ip = get_ip() #Window objects self.listWidget = self.ui.listWidget self.lineEdit = self.ui.lineEdit self.sendButton = self.ui.sendButton self.ui.actionConnect_to_user.triggered.connect(self.set_ip) self.ui.actionSet_name.triggered.connect(self.set_name) self.sendButton.clicked.connect(self.send) self.lineEdit.returnPressed.connect(self.send) self.name = "User" self.target_ip = "127.0.0.1" self.outbound = None self.inbound = InboundSocket(5, self.listWidget, self.ip) self.thread = Thread(target=self.inbound.listen, args=(self.listWidget,)) self.thread.start() self.show()
def verify_connection(self): ips = getip.get_ip() # LAN & WAN reachable if ips[0] and ips[1]: return True else: return False
def first_boot_entry(self): # msg = 'log start @%s' % (str(platform)) msg = '\nlog start @%s, IP:%s, OS:%s, Name:%s' % ( gethostname(), str( getip.get_ip()[0]), platform, self.name_of_master) self.append_log(msg, time_stamp=0) self.append_log('*' * len(msg), time_stamp=0)
def __init__(self, start_ip, end_ip): self.start_ip = start_ip self.end_ip = end_ip self.lost, self.found = [], [] self.local_ip = getip.get_ip()[0] a = self.local_ip.split('.') self.router = a[0] + '.' + a[1] + '.' + a[2] + '.' self.search_ping()
def ipfinder(): address = '<brodcast>' print "Finding Server IP, make sure you have UsoroServer running on your device!" getip = get_ip(address, port) print "IP Found, connecting!" ip = unicode(getip.handle_read()) print ip return ip
def __init__(self, master=None, **kwargs): self.master = master #if filename != [] and path !=[]: #self.path = path #self.filename = filename self.local_ip = getip.get_ip()[0] self.valid_pis, self.non_valid_pis = [], [] self.load_pi_list(kwargs) self.check_valid_pi()
def init_parameters(): global devices, sched_headers, days, tol, device_state, start_time, bg_window, devices_headers, ip, rpi_1, rpi_2 sched_headers = [ "Task #", "Enable/Disable", "Days", "Start Hour", "End Hour", "Device", 'Next On/Off' ] days = [2, 3, 4, 5, 6, 7, 1] tol = 0.4 # 2*tol = time tolerance for executing / periodical check devices = ["dev1", "dev2", "dev3", "dev4"] device_state = ['off' for y in range(len(devices))] devices_headers = ["Device" + str(i) for i in range(1, len(devices) + 1)] bg_window = "DeepSkyBlue4" start_time = datetime.datetime.now() ip = getip.get_ip() rpi_1 = rpi_relay('192.168.2.113')
def start_check(): status = {} record_list = [] try: _args = sys.argv[1] ip = get_ip() except: _args = None ip = None else: try: record = get_record(_args) status['code'] = OK status['msg'] = '获取更新域名成功' status['data'] = record except: status['code'] = FAILD status['msg'] = '获取域名信息失败,请检查域名及网络' if not ip: status['code'] = FAILD status['msg'] = '无法获取ip,请检查网络' status['ip'] = ip return status
main_topic = file_param["MAIN_TOPIC"] group_topic = file_param["GROUP_TOPIC"] msg_topic = file_param["MSG_TOPIC"] device_topic = file_param["DEVICE_TOPIC"] ####################################################### # Run Switch start_switch_code() # Run Watch_dog service loc_double_switch.use_watch_dog() # Run Local schedule #start_schedule() ## Run Gmail service start_gmail() ## Notify after boot loc_double_switch.notify_by_mail(subj='HomePi:%s boot summery' % device_name, body='Device loaded successfully @%s' % getip.get_ip()[0]) # Run MQTT service start_mqtt_service() sleep(1) pub_msg('System Boot') # Boot test PBit()
def signal_handler(signal, frame): print('quit') lcd.lcd_clear() sys.exit(0) lcd = lcddriver.lcd() # register signal handler to clear screen on quit signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) # change working directory to where this script resides, so # getip.sh can be located and executed. #script_path = sys.argv[0] #script_path_dir = os.path.dirname(script_path) #print "cd into " + script_path_dir #os.chdir(script_path_dir) while True: #lcd.lcd_display_string(datetime.datetime.now().strftime("%Y-%m-%d"), 1) lcd.lcd_display_string(datetime.datetime.now().strftime("%Y-%m-%d %H:%M"), 1) #f = os.popen("sh getip.sh") #str = f.read(32) ip = getip.get_ip() ip = ip + (" "*(16-len(ip))) lcd.lcd_display_string(ip, 2) time.sleep(5)
continue status = update(r['RecordId'], r['RR'], ip) status['date'] = datetime.now() status.update({'update_domain': r['RR']}) except: status['code'] = FAILD status['msg'] = '程序更新失败,请检查网络或程序' return status if __name__ == "__main__": start_status = start_check() while True: if start_status['code'] == OK: ip = get_ip() status = ddns(ip, start_status['data']) if status['code'] == OK or status['code'] == NOUPDATE: print(status) start_status = start_check() sleep(300) else: start_status = start_check() status = ddns(old_ip, ip, start_status['data']) print(status) sleep(300) else: print(status) start_status = start_check() sleep(300)
def __init__(self, ip=None, alias='HomePi-AlarmSys monitor', listen_pins=[21, 20], trigger_pins=[16, 26], log_filepath='', device_topic=None, msg_topic=None, alert_topic=None, group_topics=None, broker='192.168.2.120', qos=0, username=None, password=None): # listen_pins = [sys.arm, alarm.on], trigger_pins=[full, home] # ## MQTT self.alert_topic = alert_topic self.msg_topic = msg_topic self.device_topic = device_topic # ## # ## GPIO self.factory = None self.fullarm_hw = None self.homearm_hw = None self.sysarm_hw = None self.alarm_hw = None # ## self.alias = alias self.log_filename = log_filepath + 'AlarmMonitor.log' self.last_state = [None, None, None, None] self.alarm_on_flag = False self.alarm_start_time = None # ## # operated from remote,but ip belongs to AlarmSys if ip is not None and ip != getip.get_ip()[0]: self.factory = PiGPIOFactory(host=ip) self.ip_pi = ip # case or run locally at AlarmSys else: self.ip_pi = getip.get_ip()[0] # ## Start Services Thread.__init__(self) self.mqtt_client = MQTTClient(sid='alarm_mqtt', topics=[device_topic, group_topics], topic_qos=qos, host=broker, username=username, password=password) self.telegram_bot = TelegramBot() self.start_mqtt_service() self.start_telegram_service() self.logger = Log2File(self.log_filename, name_of_master=self.alias, time_in_log=1, screen=1) self.last_log_record = None # define below self.hardware_gpio(trigger_pins, listen_pins) self.notify('logfile: [%s]' % self.log_filename)
return None logging.info("modify_record SUCCESSED, info: [%s.%s => %s][%s] ok" % (config['sub_domain'], config['domain'], ip, status_code)) # print(resp) if __name__ == '__main__': logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)-8s : %(message)s') logging.info("watching ip for ddns: %s.%s" % (config['sub_domain'], config['domain'])) while True: record = get_record() current_ip = get_ip() record_ip = record.get('record_ip') record_id = record.get('record_id') interval = int(config['interval']) if current_ip: if current_ip != record_ip: logging.info('ip address change detected [%s][%s]' % (record_ip, current_ip)) modify_record(record_id, current_ip) else: logging.info('no change of ip address') else: logging.error('get current ip FAILED.') logging.info('wait %s seconds and try again', str(interval)) time.sleep(interval)