def main(): # Get the application data f = open(".access_token", "r") keydata = json.loads(f.read()) # Initiate the moves object m = Moves(keydata) # Initiate the com link with arduino c = Comm() loops = 0 # Run program loop while True: state = 0 # Load date interval currentDate = datetime.datetime.now().strftime("%Y%m%d") oldDate = (datetime.datetime.now() - datetime.timedelta(days=30)).strftime("%Y%m%d") data = m.getRangeSummary(oldDate, currentDate) processor = DataProcessor(data) msg = processor.getDuration() print msg c.send(msg) # Sleep program untill next check time.sleep(30)
def get(job_info,**comm_kwargs): #print comm_kwargs comm = Comm(job_info, **comm_kwargs) comm.set_attr(log_file_name="BCCard_crawl_profile.log") for t in range(DEFAULT_RETRY_COUNT): comm = get_attempt(comm) try: if comm.driver: comm.driver.quit() comm.driver = None except: comm.add_err("ERROR_RETRIABLE_problem_in_closing_webdriver", tb_msg=traceback.format_exc(), SC=True) return comm if comm.last_e_msg == "OK": comm.logger.error(">>>ALL PROCESS IS DONE") return comm elif "ERROR_DO_NOT_RETRY" in comm.last_e_msg: return comm else: time.sleep(5) comm.add_err("ERROR_DO_NOT_RETRY_retry_count_exceed") return comm
def main(): # Get the application data f = open('.access_token', 'r') keydata = json.loads(f.read()) # Initiate the moves object m = Moves(keydata) # Initiate the com link with arduino c = Comm() loops = 0 # Run program loop while True: state = 0 if loops is 0: # Load date interval currentDate = datetime.datetime.now().strftime('%Y%m%d') oldDate = (datetime.datetime.now() - datetime.timedelta(days=30)).strftime('%Y%m%d') data = m.getRangeSummary(oldDate, currentDate) processor = DataProcessor(data) raw = processor.newDataProcessor() if processor.checkMoving(): state = 1 # Check realtime realtime = datetime.datetime.strptime(requests.get('http://studier.albinhubsch.se/lucy-light').text, "%Y-%m-%d %H:%M:%S") now = datetime.datetime.now() if realtime + datetime.timedelta(minutes=10) > now: state = 1 msg = str(state) + ',' + raw c.send(msg) if loops < 10: loops += 1 else: loops = 0 # Sleep program untill next check time.sleep(6)
def __init__(self, connection): Comm.__init__(self, connection) self.rxCallback = self.responseCallback self.onPing = Event() self.onEraseMemory = Event() self.onNEntries = Event() self.onEntry = Event() self.onGetTime = Event() self.onSetTime = Event() self.onGetHAlarm = Event() self.onSetHAlarm = Event() self.onGetLAlarm = Event() self.onSetLAlarm = Event() self.onGetCurrentTemp = Event()
def get(job_info, **comm_kwargs): comm = Comm(job_info, **comm_kwargs) comm.set_attr(url="https://spib.wooribank.com/pib/Dream?withyou=CMLGN0001", log_file_name="Woori_crawl_profile.log") for t in range(DEFAULT_RETRY_COUNT): comm = get_attempt(comm) if comm.last_e_msg == "OK": comm.logger.error(">>>ALL PROCESS IS DONE") return comm elif "ERROR_DO_NOT_RETRY" in comm.last_e_msg: return comm else: time.sleep(5) comm.add_err("ERROR_DO_NOT_RETRY_retry_count_exceed") return comm
def main(): args = parse_args() ros_is_on = args['ros'] port = args['port'] baud = args['baud'] traj = args['traj'] step_is_on = args['step'] logString(list_ports()) logString("Attempting connection to embedded") logString("\tPort: " + port) logString("\tBaud rate: " + str(baud)) num_tries = 0 comm = Comm() while (True): try: with serial.Serial(port, baud, timeout=0) as ser: logString("Connected") comm.start_up(ser, ros_is_on, traj, step_is_on) comm.begin_event_loop() except serial.serialutil.SerialException as e: if (num_tries % 100 == 0): if (str(e).find("FileNotFoundError")): logString( "Port not found. Retrying...(attempt {0})".format( num_tries)) else: logString( "Serial exception. Retrying...(attempt {0})".format( num_tries)) time.sleep(0.01) num_tries = num_tries + 1
__dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(__dir + "/model") sys.path.append(__dir + "/utils") sys.path.append(__dir + "/collectors") from Config import Config from Comm import Comm import json config = Config(os.path.dirname(os.path.realpath(__file__)) + "/test/config.json") # TODO collectors = config.getCollectors() inventory = [] for collector_name in collectors: try: module_ = __import__(collector_name) collector = getattr(module_, collector_name)() collector.load() dataset = config.getData(collector_name) for data in dataset: inventory.append(collector.retrieveData()) except: print "No " + collector_name + " collector defined!" comm = Comm("localhost") comm.send(json.dumps(inventory))
import lcd # Connect the Grove Button to digital port D2 button = 2 # Connect the Grove Buzzer to digital port D8 buzzer = 8 grovepi.pinMode(button,"INPUT") grovepi.pinMode(buzzer,"OUTPUT") lcd.setRGB(128,0,0) #red worker1_ip = "192.168.0.105" worker2_ip = "192.168.0.100" worker1 = Comm(worker1_ip) worker2 = Comm(worker2_ip) time.sleep(2) #Step 1. Wait for user to press button button_flag = True while button_flag: try: value = grovepi.digitalRead(button) # 0 not pressed, 1 pressed if value == 1: set button_flag False time.sleep(.5) except TypeError: print(TypeError)
comm.driver.quit() comm.driver = None except: comm.add_err("ERROR_DO_NOT_RETRY_problem_in_webdriver", tb_msg=traceback.format_exc(), SC=True) return comm return comm else: time.sleep(10) try: if comm.driver: comm.driver.quit() comm.driver = None except: comm.add_err("ERROR_DO_NOT_RETRY_problem_in_webdriver", tb_msg=traceback.format_exc(), SC=True) return comm return comm if __name__ == "__main__": job_info = {'creds': {'cred_user_id': 'murane', 'cred_user_pw': 'Tpsxl40!', 'cred_acc_no': '110385994336'}} comm = Comm(job_info) comm.set_attr(url="https://open.shinhan.com/index.jsp", isEncoded=False) comm = login(comm) print comm.last_e_msg
def test_comm(self): comm = Comm('localhost') comm.send('test') self.assertTrue(True)
from Comm import Comm import os import time numOfPeers = 1 # number of peers to talk to CommComp1 = Comm(numOfPeers) # instantiate the Comm class CommComp1.do(numOfPeers, [ os.path.join('.', 'fileTran', 'entity_1'), os.path.join('.', 'fileTran', 'entity_2') ], [ os.path.join('.', 'fileRecv', 'entity_1'), os.path.join('.', 'fileRecv', 'entity_2') ], ['10.206.203.243', '10.152.144.160']) ######################################################################################## print '.......simulation going on.........' time.sleep(5) print '.....simulation done. ready for transmission .........' ######################################################################################## CommComp2 = Comm(numOfPeers) # instantiate the Comm class CommComp2.do(numOfPeers, [ os.path.join('.', 'fileTran', 'entity_2'), os.path.join('.', 'fileTran', 'entity_2') ], [ os.path.join('.', 'fileRecv', 'entity_2'), os.path.join('.', 'fileRecv', 'entity_2') ], ['10.206.203.243', '10.152.144.160']) ######################################################################################## print '.......simulation going on.........'
SC=True) return comm comm.add_err("ERROR_DO_NOT_RETRY_retrial_num_excess", tb_msg=traceback.format_exc()) return comm if __name__ == "__main__": job_info = { 'creds': { 'cred_user_id': 'zakk95', 'cred_user_pw': 'Tpsxl80@' } } comm = Comm(job_info=job_info) comm.set_attr(url="https://www.bccard.com/app/card/MainActn.do", isEncoded=False) comm = login(comm) """ flag = 1 while True: if flag == 1: job_info = {'creds':{'cred_user_id':'zakk95','cred_user_pw':'Tpsxl80@'}} elif flag == 2: job_info = {'creds':{'cred_user_id':'zakk9512','cred_user_pw':'Tpsxl80@'}} #id elif flag == 3: job_info = {'creds':{'cred_user_id':'zakk95','cred_user_pw':'Tpsxl80@ef1'}} #pw comm = Comm(job_info=job_info)
from Comm import Comm #import Server import time neighbor1_ip = Comm("192.168.0.105") neighbor2_ip = Comm("192.168.0.100") neighbor1_ip.send( {'message': 'fyi', 'value': "Test"} ) neighbor2_ip.send( {'message': 'fyi', 'value': "Test"} ) flag1 = True flag2 = True while flag1 and flag2: if flag1: table1 = neighbor1_ip.get_table() print('neighbor1 sent: ' + str( table1 )) flag1 = table1 == [] #if still empty then keep flag True if flag2: table2 = neighbor2_ip.get_table() print('neighbor2 sent: ' + str( table2 )) flag2 = table2 == [] #if still empty then keep flag True time.sleep( .5 ) print( 'got them both' )
return comm try: if comm.driver: comm.driver.quit() comm.driver = None except: comm.add_err("ERROR_DO_NOT_RETRY_problem_in_webdriver", tb_msg=traceback.format_exc(), SC=True) return comm return comm if __name__ == "__main__": job_info = { 'creds': { 'cred_user_id': 'zakk95', 'cred_user_pw': 'TPSXL40', 'cred_acc_no': '46543138745124' } } comm = Comm(job_info) comm.set_attr(url="https://obank1.kbstar.com/quics?page=C018897&QViewPC=Y", isEncoded=False) comm = login(comm) print comm.last_e_msg
return comm return comm else: time.sleep(10) try: if comm.driver: comm.driver.quit() comm.driver = None except: comm.add_err("ERROR_DO_NOT_RETRY_problem_in_webdriver", tb_msg=traceback.format_exc(), SC=True) return comm return comm if __name__ == "__main__": job_info = { 'creds': { 'cred_user_id': 'zakk95', 'cred_user_pw': 'uE^9z@', 'cred_acc_no': '1002442773027' } } comm = Comm(job_info=job_info) comm.set_attr(url="https://spib.wooribank.com/pib/Dream?withyou=CMLGN0001", isEncoded=False) comm = login(comm)