Example #1
0
    def _print_tokens(self):
        if self._errors:
            ERRORMSG = str(len(
                self._errors)) + " Errors were Found!, cannot continue"
            alert(self._debug, 1, ERRORMSG)

        print('\n\n[Lexer] ----- SYMBOL TABLE -----')
        for x in self.tokens:
            print("{:<8} {:<15} {:<10}".format(x.line, x.symbol, x.kind))
Example #2
0
 def _send_alert(self, alert_code, line=False):
     if alert_code == 'unclosed_comment':
         self._errors.append([line, 'unclosed_comment'])
         ERRORMSG = 'Unclosed comment on line ' + str(line)
         alert(self._debug, 2, ERRORMSG)
     elif alert_code == 'invalid':
         self._errors.append([self._current_line, 'invalid'])
         ERRORMSG = 'Invalid symbol \"' + str(''.join(self._current_symbol)) \
               + '\" on line ' + str(self._current_line)
         alert(self._debug, 2, ERRORMSG)
def index():
    acc_data = request.json
    if len(acc_data) > 1:
        data = acc_data
        query = db.collection('users_patients').where('device_id', '==',
                                                      acc_data["device_id"])
        docs = query.limit(1).stream()
        for doc in docs:
            patient_id = doc.id
            patient_name = doc.to_dict()["firstname"] + " " + doc.to_dict(
            )["lastname"]
        acc_data["patient_id"] = patient_id
        query = db.collection('accidents').add(acc_data)
        #get responsibles and store data in firestore
        query = db.collection('responsibles').where('patients',
                                                    'array_contains',
                                                    patient_id)
        docs = query.stream()
        resples_ids = []
        resples_emails = []
        resples_phones = []
        resples_notfs = []
        warning_notification = patient_name + " maybe in danger situation ,temperature : " + str(
            acc_data["temp"])
        danger_notification = patient_name + " is in danger situation , he fell down ,temperature : " + str(
            acc_data["temp"])
        if data["down"] == 1:
            title = "Your Patient Fell Down"
            color = "#df4759"
            notification = danger_notification
        else:
            title = "Check The Situation Of Your Patient"
            color = "	#ffc107"
            notification = warning_notification
        for doc in docs:
            resples_ids.append(doc.id)
            notifications = doc.to_dict()["notifications"]
            notifications.append(notification)
            resples_notfs.append(notifications)
            resples_emails.append(doc.to_dict()["email"])
            resples_phones.append(doc.to_dict()["phone"])
        for re_id, res_notif in zip(resples_ids, resples_notfs):
            query = db.collection('responsibles').document(re_id).update(
                {'notifications': res_notif})
        #notify the responsible in email and phone number
        for email in resples_emails:
            alert(title, notification, email, color)
        return app.response_class(response=json.dumps(data),
                                  status=200,
                                  mimetype='application/json')
    else:
        return app.response_class(response=json.dumps(acc_data),
                                  status=403,
                                  mimetype='application/json')
Example #4
0
def report(errors):
    if not errors:
        print "No errors."
        return
    print "Got errors:"
    for error in errors:
        print "   ", error
    alert(type='sanity-check-failures',
          details={'errors': errors},
          text='\n'.join(errors),
          color='danger')
Example #5
0
def report(errors):
    if not errors:
        print "No errors."
        return
    print "Got errors:"
    for error in errors:
        print "   ", error
    alert.alert(type='sanity-check-failures',
                details={'errors': errors},
                text='\n'.join(map(str, errors)),
                color='danger')
def main():
    seri = "/dev/ttyACM0"
    while True:
        try:  #check mail
            send_command(seri)
        except:
            print("No commands given")

        try:  #check arduino and alert user if needed
            alert(seri)
        except:
            print("No new emails")
Example #7
0
def main(argv):
    parser = setup_parser()
    args = parser.parse_args(argv)
    if args.dry_run:
        logging.getLogger().setLevel(logging.INFO)
        alertlib.enter_test_mode()

    rc = run_with_timeout(args.duration, [args.command] + args.arg,
                          args.signal, args.kill_after, args.cwd)
    if rc == 124:
        alert.alert('TIMEOUT running %s' % args.command, args)
    return rc
Example #8
0
def main(argv):
    parser = setup_parser()
    args = parser.parse_args(argv)
    if args.dry_run:
        logging.getLogger().setLevel(logging.INFO)
        alertlib.enter_test_mode()

    rc = run_with_timeout(args.duration, [args.command] + args.arg,
                          args.signal, args.kill_after, args.cwd)
    if rc == 124:
        alert.alert('TIMEOUT running %s' % args.command, args)
    return rc
Example #9
0
def close_server(msg):
    if os.path.exists(close_flag_filename):
        print "Not closing myself again."
        return
    txn = redis_shell.pipeline()
    vps_util.actually_close_proxy(name=instance_id, ip=ip, pipeline=txn)
    alert(type='proxy-closed',
          details={'reason': msg},
          text="*Closed* because I " + msg,
          color='good',
          pipeline=txn)
    txn.execute()
    flag_as_done(close_flag_filename)
Example #10
0
def run():
    usage = psutil.disk_usage('/').percent
    print "Usage: %s%%" % usage
    if usage < critical_threshold:
        return
    print "Disk usage *critical*; clearing big files in /var/log and rebooting!"
    alert("disk-usage-critical",
            details={'usage': usage},
            text="Using %s%% of disk; clearing big files in /var/log !" % usage,
            color="danger")
    os.path.walk('/var/log', delete_big_files, None)
    # Brutish way to restart all affected services.
    os.system('/sbin/reboot -f')
Example #11
0
def main():
	stdout, stdin = popen2('df .')
	stdout.readline() #stip column headers
	data = [field for field in stdout.readline().split(' ') \
				if field.endswith('%')]
	used = int(data[0][:-1])
	if used > 70:
		alert.alert('Disk space used at '+str(used)+'%' , '')

	stdout, stdin = popen2("free -tm | awk '/Mem:/ {print $4}'")
	free = int(stdout.readline().rstrip())
	if free < 45:
		alert.alert('Memory free at %s MB' % free, '')
Example #12
0
def run():
    usage = psutil.disk_usage('/').percent
    print "Usage: %s%%" % usage
    if usage < critical_threshold:
        return
    print "Disk usage *critical*; clearing big files in /var/log and rebooting!"
    alert("disk-usage-critical",
          details={'usage': usage},
          text="Using %s%% of disk; clearing big files in /var/log !" % usage,
          color="danger")
    os.path.walk('/var/log', delete_big_files, None)
    # Brutish way to restart all affected services.
    os.system('/sbin/reboot')
Example #13
0
def close_server(msg):
    if os.path.exists(close_flag_filename):
        print "Not closing myself again."
        return
    txn = redis_shell.pipeline()
    vps_util.actually_close_proxy(name=instance_id, ip=ip, pipeline=txn)
    alert(type='proxy-closed',
          details={'reason': msg},
          text="*Closed* because I " + msg,
          color='good',
          pipeline=txn)
    txn.execute()
    flag_as_done(close_flag_filename)
def get_distance():
    global count
    while True:
        dist = abs(distance(GPIO_TRIGGER, GPIO_ECHO))

        if 0 < dist < 10:  ##if distance <30 --> alert
            alert(piezo_p, led2)
            count += 1

        if dist > 10:
            piezo_p.ChangeDutyCycle(
                0)  ##if distance >30 --> alert off (volume 0)

        time.sleep(1.2)
Example #15
0
def bdd():
    #---------------------------------------------------------------------------------
    #	création de la bdd à partir du fichier s1RES
    #---------------------------------------------------------------------------------
    list = [None] * 9
    i = 0
    with open("s1RES.txt", "r") as f:
        for line in f:
            for word in line.split():
                liste[i] = word
                i += 1
        f.close()

    #---------------------------------------------------------------------------------
    #	création de la table
    #---------------------------------------------------------------------------------
    connect = sqlite3.connect('sonde.db')
    x = connect.cursor()
    x.execute('''CREATE TABLE IF NOT EXISTS sonde (
		hostname TEXT,
		cpu INTEGER,
		ram INTEGER,
		swap INTEGER,
		disque INTEGER,
		utilisateur INTEGER,
		processus INTEGER,
		time DATE,
		heure INTEGER
		)''')

    #---------------------------------------------------------------------------------
    #	suppression des anciennes données
    #---------------------------------------------------------------------------------
    x.execute("DELETE FROM sonde WHERE heure != strftime('%H','now')+2")

    #---------------------------------------------------------------------------------
    #	insert valeurs
    #---------------------------------------------------------------------------------
    x.execute("INSERT INTO sonde VALUES(?,?,?,?,?,?,?,?,?+2)", liste)
    for row in x.execute('SELECT * FROM sonde'):
        print(row)

    #---------------------------------------------------------------------------------
    #	récupère les données et les envoie dans le module alert
    #---------------------------------------------------------------------------------
    x.execute("""SELECT cpu, ram, disque, time FROM sonde""")
    data = x.fetchone()
    alert.alert(data[0], data[1], data[2])
    connection.commit()
    connection.close()
Example #16
0
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " + str(e)

        timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp, self.TIMEZONE)

        aaa = 0
        for entity in feed.entity:
            # Trip update represents a change in timetable
            if entity.HasField('trip_update'):
                self.tripUpdates.append([])
                update = tripupdate.tripupdate()
                self.tripUpdates[len(self.tripUpdates) - 1].append(
                    entity.trip_update.trip.trip_id)
                self.tripUpdates[len(self.tripUpdates) - 1].append(
                    entity.trip_update.trip.route_id)
                self.tripUpdates[len(self.tripUpdates) - 1].append(
                    entity.trip_update.trip.start_date)
                self.tripUpdates[len(self.tripUpdates) - 1].append(
                    entity.trip_update.stop_time_update[0].stop_id[-1])
                for stop in entity.trip_update.stop_time_update:
                    update.futureStops[stop.stop_id] = [{
                        'arrivaltime':
                        stop.arrival.time or None
                    }, {
                        'departuretime':
                        stop.departure.time or None
                    }]
                self.tripUpdates[len(self.tripUpdates) - 1].append(
                    update.futureStops)
                self.tripUpdates[len(self.tripUpdates) - 1].append(timestamp)
                self.tripUpdates[len(self.tripUpdates) - 1].append("-1")
                self.tripUpdates[len(self.tripUpdates) - 1].append(-1)
                self.tripUpdates[len(self.tripUpdates) - 1].append(-1)

            if entity.HasField('vehicle'):
                self.tripUpdates[len(self.tripUpdates) -
                                 1][6] = entity.vehicle.stop_id
                #print "$$$$$$$$$$" +newItem.currentStopId+ "$$$$$$$$$$"
                self.tripUpdates[len(self.tripUpdates) -
                                 1][7] = entity.vehicle.timestamp
                #print "!!!!!!!!!!" +str(newItem.vehicleTimeStamp)+ "!!!!!!!!!!"
                self.tripUpdates[len(self.tripUpdates) -
                                 1][8] = entity.vehicle.current_status
                #print "**********" +str(newItem.currentStopStatus)+ "**********"

            if entity.HasField('alert'):
                a = alert.alert()
                a.alertMessage = entity.alert.header_text.translation
                #a.alertMessage = entity.alert.header_text.translation.text
                self.alerts.append(a)

            #### INSERT ALERT CODE HERE #####

        return self.tripUpdates
Example #17
0
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " +str(e)
	

	timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp,self.TIMEZONE)
	
	for entity in feed.entity:
	    # Trip update represents a change in timetable
	    if entity.trip_update and entity.trip_update.trip.trip_id:
		update = tripupdate.tripupdate()
		
		##### INSERT TRIPUPDATE CODE HERE ####			

	    if entity.vehicle and entity.vehicle.trip.trip_id:
	    	v = vehicle.vehicle()
		##### INSERT VEHICLE CODE HERE #####
	    
	    if entity.alert:
                a = alert.alert()
		#### INSERT ALERT CODE HERE #####

	return self.tripUpdates
Example #18
0
 def warnAndQuit(self,msg):
     """
     Display alert and (maybe) quit the plugin
     """
     self.lasagna.alert = alert(self.lasagna,alertText=msg)
     self.lasagna.stopPlugin(self.__module__) #This will call self.closePlugin
     self.lasagna.pluginActions[self.__module__].setChecked(False) #Uncheck the menu item associated with this plugin's name
Example #19
0
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " +str(e)
	

	timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp,self.TIMEZONE)
	
	for entity in feed.entity:
	    # Trip update represents a change in timetable
	    if entity.trip_update and entity.trip_update.trip.trip_id:
		update = tripupdate.tripupdate()

		##### INSERT TRIPUPDATE CODE HERE ####	

	    if entity.vehicle and entity.vehicle.trip.trip_id:
	    	v = vehicle.vehicle()

		##### INSERT VEHICLE CODE HERE #####
	    
	    if entity.alert:
                a = alert.alert()=

                #### INSERT ALERT CODE HERE #####

	return self.tripUpdates
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " + str(e)

        self.timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(self.timestamp, self.TIMEZONE)

        for entity in feed.entity:
            # Trip update represents a change in timetable
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()
                ##### INSERT TRIPUPDATE CODE HERE ####
                update.tripId = str(entity.trip_update.trip.trip_id)
                update.routeId = str(entity.trip_update.trip.route_id)
                update.startDate = entity.trip_update.trip.start_date
                update.direction = str(entity.trip_update.trip.trip_id[10])
                curr_vehicle = self.returnVehicle(update.tripId)
                num = 0
                for i in entity.trip_update.stop_time_update:
                    update.futureStops[num] = (
                        '"'
                        + str(i.stop_id)
                        + '": [{"arrivalTime": '
                        + str(i.arrival.time)
                        + '}, {"departureTime": '
                        + str(i.departure.time)
                        + "}]"
                    )
                    #                    print update.futureStops[num]
                    num += 1
                if curr_vehicle is not None:
                    update.vehicleData = curr_vehicle
                self.tripUpdates.append(update)
            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                ##### INSERT VEHICLE CODE HERE #####
                v.currentStopNumber = entity.vehicle.current_stop_sequence
                v.currentStopId = str(entity.vehicle.stop_id)
                v.timestamp = entity.vehicle.timestamp
                v.currentStopStatus = entity.vehicle.current_status
                v.trip_id = str(entity.vehicle.trip.trip_id)
                v.start_date = entity.vehicle.trip.start_date
                v.route_id = entity.vehicle.trip.route_id
                self.vehicles.append(v)
                cor_trip = self.returnTrip(v.trip_id)
                cor_alert = self.returnAlert(v.trip_id)
                if cor_trip is not None:
                    cor_trip.vehicleData = v

            if entity.alert:
                a = alert.alert()
                #### INSERT ALERT CODE HERE #####
                a.alertMessage = entity.alert.header_text.translation
                self.alerts.append(a)

        return self.tripUpdates
 def warnAndQuit(self,msg):
     """
     Display alert and (maybe) quit the plugin
     """
     self.lasagna.alert = alert(self.lasagna,alertText=msg)
     self.lasagna.stopPlugin(self.__module__) #This will call self.closePlugin
     self.lasagna.pluginActions[self.__module__].setChecked(False) #Uncheck the menu item associated with this plugin's name
Example #22
0
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " +str(e)

        timestamp = feed.header.timestamp
        print "Timestamp: ", timestamp
        nytime = datetime.fromtimestamp(timestamp, self.TIMEZONE)
        print "NYC Time: ", nytime

        self.timestamp = timestamp
        self.tripUpdates = []
        self.alerts = []

        for entity in feed.entity:
            # Trip update represents a change in timetable
            if entity.trip_update and entity.trip_update.trip.trip_id:
                # Assign the tripupdate fields
                t = tripupdate.tripupdate()
                t.tripId = entity.trip_update.trip.trip_id
                t.routeId = entity.trip_update.trip.route_id
                t.startDate = entity.trip_update.trip.start_date
                t.direction = entity.trip_update.trip.direction_id

                # There can be many StopTimeUpdate messages
                for st_update in entity.trip_update.stop_time_update:
                    times = []
                    times.append({"arrivalTime": st_update.arrival.time})
                    times.append({"departureTime": st_update.departure.time})
                    t.futureStops[st_update.stop_id] = times

                self.tripUpdates.append(t)

            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                v.currentStopNumber = entity.vehicle.current_stop_sequence
                v.currentStopId = entity.vehicle.stop_id
                v.timestamp = entity.vehicle.timestamp
                v.currentStopStatus = entity.vehicle.current_status

                # Using the trip_id on a vehicle, associate that vehicle with the trip update object
                vehicleTripId = entity.vehicle.trip.trip_id
                self.setVehicleDataOnTripUpdate(vehicleTripId, v)

            if entity.HasField('alert') and entity.alert:
                a = alert.alert()
                a.alertMessage = entity.alert.header_text.translation[0].text
                for informed_entity in entity.alert.informed_entity:
                    tripId = informed_entity.trip.trip_id
                    a.tripId.append(tripId)
                    a.routeId[tripId] = informed_entity.trip.route_id
                    a.startDate[tripId] = informed_entity.trip.start_time
                self.alerts.append(a)

        return self.tripUpdates
Example #23
0
def loop():
    if is_approaching():
        alert()
        add_new_pothole()
        time.sleep(1)
        break
    elif not is_approaching():
        if is_image_pothole():
            alert()
            add_new_pothole()
            time.sleep(1)
            break
        elif not is_image_pothole():
            if is_accel_pothole():
                add_new_pothole()
                time.sleep(1)
            elif not_accel_pothole():
                break
def check(tick):
    check_rank = tick % 8
    check_object = None
    check_dist = "Noop"

    if check_rank == 0:
        check_object = archlinux
        check_dist = "Arch Linux"
        check_name = "archlinux"
    elif check_rank == 1:
        check_object = debian
        check_dist = "Debian"
        check_name = "debian"
    elif check_rank == 2:
        check_object = centos
        check_dist = "CentOS"
        check_name = "centos"
    elif check_rank == 3:
        check_object = ubuntu
        check_dist = "Ubuntu"
        check_name = "ubuntu"
    elif check_rank == 4:
        check_object = linuxmint
        check_dist = "LinuxMint"
        check_name = "linuxmint"
    elif check_rank == 5:
        check_object = epel
        check_dist = "EPEL"
        check_name = "epel"
    elif check_rank == 6:
        check_object = postgresql
        check_dist = "PostgreSQL"
        check_name = "postgresql"
    elif check_rank == 7:
        check_object = openSUSE
        check_dist = "openSUSE"
        check_name = "opensuse"

    result, is_ok= check_object.check_it()
    if not is_ok:
        alert.alert(check_dist, result)

    with open(os.path.join("/srv/mirrors/status", check_name + "_status"), "w") as output:
        output.write(result)
Example #25
0
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " +str(e)
	

        timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp,self.TIMEZONE)
	
        for entity in feed.entity:
            # Trip update represents a change in timetable
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()
		
                ##### INSERT TRIPUPDATE CODE HERE ####	

                update.tripId       = entity.trip_update.trip.trip_id
                update.routeId      = entity.trip_update.trip.route_id
                update.startDate    = entity.trip_update.trip.start_date
                update.direction    = entity.trip_update.stop_time_update[-1].stop_id[-1]
                update.vehicleData  = entity.trip_update.vehicle
		newkey = entity.trip_update.stop_time_update[-1].stop_id
		low    = entity.trip_update.stop_time_update[-1].arrival.time
		hi     = entity.trip_update.stop_time_update[-1].departure.time
                update.futureStops.update({ newkey : [low,hi] })# Format {stopId : [arrivalTime,departureTime]})

            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                
                ##### INSERT VEHICLE CODE HERE #####
                
                v.currentStopNumber = entity.vehicle.current_stop_sequence
                v.currentStopId     = entity.vehicle.stop_id
                v.timestamp         = entity.vehicle.timestamp
                v.currentStopStatus = entity.vehicle.current_status
            if entity.alert:
                a = alert.alert()
                
                #### INSERT ALERT CODE HERE #####
                #print entity.alert.informed_entity
                a.tripId            = entity.trip_update.trip.trip_id
                a.routeId           = entity.trip_update.trip.route_id
                a.startDate         = entity.trip_update.trip.start_date
		try:
                    a.alertMessage  = entity.alert.header_text.translation.text
		except:
		    a.alertMessage  = ''
	
	self.tripUpdates.append(update)
	self.tripUpdates.append(v)
	self.tripUpdates.append(a)

	return self.tripUpdates
Example #26
0
def check(driver,
          url,
          no_keyword='无货',
          yes_keyword='有货',
          out_keyword='下柜',
          name=None):
    driver.get(url)
    page_source = driver.page_source
    desc = '{} {}'.format(url, name)
    if no_keyword in page_source:
        logger.info('{} check result: 无货'.format(desc))
        return False
    elif out_keyword in page_source:
        logger.info('{} check result: 下架'.format(desc))
        return False
    elif yes_keyword in page_source:
        logger.info('{} check result: 有货'.format(desc))
        alert('{} in sell'.format(desc))
        return True
    logger.warning('{} check result: unkown error'.format(desc))
    return False
Example #27
0
def check_all(driver=None, do_order=False):
    need_driver = not driver
    if need_driver:
        driver = get_driver()
    products = get_all_products()

    for product in products:
        name = product.get('name', '')
        url = product['url']
        desc = '{} {}'.format(url, name)
        if check(driver, product['url'], name=name) and do_order:
            if order(driver):
                msg = '{} 已尝试提交订单,请尽快查看并付款'.format(desc)
                logger.info(msg)
                alert(msg)
                input('已尝试提交订单,如需继续检测,请按enter')
            else:
                logger.error('{} 提交订单失败'.format(desc))
        time.sleep(0.5)
    if need_driver:
        driver.close()
Example #28
0
def check(tick):
    check_rank = tick % 8
    check_object = None
    check_dist = "Noop"
    # Archlinux
    if check_rank == 0:
        check_object = archlinux
        check_dist = "Arch Linux"
    # Debian
    elif check_rank == 1:
        check_object = debian
        check_dist = "Debian"
    # CentOS
    elif check_rank == 2:
        check_object = centos
        check_dist = "CentOS"
    # Ubuntu
    elif check_rank == 3:
        check_object = ubuntu
        check_dist = "Ubuntu"
    # LinuxMint
    elif check_rank == 4:
        check_object = linuxmint
        check_dist = "LinuxMint"
    # EPEL
    elif check_rank == 5:
        check_object = epel
        check_dist = "EPEL"
    #PostgreSQL
    elif check_rank == 6:
        check_object = postgresql
        check_dist = "PostgreSQL"
    #PostgreSQL
    elif check_rank == 7:
        check_object = openSUSE
        check_dist = "openSUSE"

    result, is_ok= check_object.check_it()
    if not is_ok:
        alert.alert(check_dist, result)
Example #29
0
	def ButtonConnectPressed(self,event):

		self.port =self.textbox2.GetValue()
		self.ip= self.textbox1.GetValue()

		if not self.textbox1.GetValue():

			error = 15
			aler = alert.alert(None, -1,"ALERT MESSAGE!!!!!!!!!!!!",error)
			aler.ShowModal()
			return

		elif not self.textbox2.GetValue() :

			error = 11
			aler = alert.alert(None, -1,"ALERT MESSAGE!!!!!!!!!!!!",error)
			aler.ShowModal()
			return

		# creaing tuple

		t = (self.ip,int(self.port))

		try:
			self.s = socket(AF_INET, SOCK_STREAM)
			self.s.connect(t)
			error = 3
			aler = alert.alert(None, -1,"        Connection success",error)
        		aler.ShowModal()
			self.button_select.Enable()
        		aler.Destroy()

		except:

			error = 1
			aler = alert.alert(None, -1,"ALERT MESSAGE!!!!!!!!!!!!",error)
        		aler.ShowModal()
			
        		aler.Destroy()
Example #30
0
def one_cycle(init_dict, manual_control_path, sensor_log_path, ml_action_log,
              alert_log, max_log_size, interval):
    """
    Executes one cycle of reading, logging, using decision and rwsponding
    Returns NONE
    """
    # read from manual control interface
    manual_control = pin_constants.load_data(manual_control_path)
    manual_results = pin_constants.load_data(MANUAL_CONTROL_PATH)
    ml_args = one_cycle_sensors(init_dict)
    log(ml_args, sensor_log_path, max_log_size)

    if manual_control["mode"] == "machine_learning":
        ml_results = ml_adapter(ml_args)
        peripheral_actions = one_cycle_peripherals(init_dict, ml_results)
    elif manual_control["mode"] == "manual":
        manual_results = {"now": {}}
        peripheral_actions = one_cycle_peripherals(init_dict, manual_results)

    alert(100, ALERT_LOG_PATH)
    log(peripheral_actions, ml_action_log, max_log_size)
    time.sleep(interval)
Example #31
0
def process_submission(reddit, submission):
	if submission is not None:
		# Connect to database.
		connection = sqlite3.connect('history.db')
		cursor = connection.cursor()
		cursor.execute(
			"SELECT * FROM data WHERE title = ? ORDER BY time_created ASC",
			(submission.title,))
		details = cursor.fetchone()
		
		if details is None:
			# Submission is not in database.
			values = (submission.id, submission.created, submission.title)
			cursor.execute(
				"INSERT INTO data VALUES (?,?,?)",
				values)
			connection.commit()
			# print('Original: ' + submission.id)
		elif submission.id != details[0]:
			# Submission is a repost.
			alert.alert(reddit, submission, details)
			print('REPOST: ' + submission.id)
		connection.close()
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " + str(e)

        timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp, self.TIMEZONE)

        for entity in feed.entity:
            # Trip update represents a change in timetable
            update = None
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()
                update.tripId = entity.trip_update.trip.trip_id
                update.routeId = entity.trip_update.trip.route_id
                update.startDate = entity.trip_update.trip.start_date
                update.direction = entity.trip_update.trip.trip_id[
                    entity.trip_update.trip.trip_id.find("..") + 2]
                update.vehicleData = entity.vehicle

                for e in entity.trip_update.stop_time_update:
                    arrivalTime = e.arrival.time
                    departureTime = e.departure.time
                    v1 = {"arrivalTime": arrivalTime}
                    v2 = {"departureTime": departureTime}
                    value = [v1, v2]
                    update.futureStops[e.stop_id] = value

            v = None
            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                v.currentStopNumber = entity.vehicle.current_stop_sequence
                v.currentStopId = entity.vehicle.stop_id
                v.timestamp = entity.vehicle.timestamp
                v.currentStopStatus = entity.vehicle.current_status

            a = None
            if entity.alert:
                a = alert.alert()
                for trip in entity.alert.informed_entity:
                    a.tripId.append(trip.trip_id)
                    a.routeId[trip.trip_id] = trip.route_id
                    a.startDate[trip.trip_id] = trip.start_date

            self.tripUpdates.append([update, v, a])

        return self.tripUpdates
Example #33
0
def manageAlerts(alertMap, alertList, value, valueType, host):

    curr_host = alertMap[host]

    curr_avg = curr_host[0][valueType]
    curr_std = curr_host[1][valueType]

    if(curr_avg + (2 * curr_std) < value):
        print("alert should be sent")
        curr_alert_index = findAlert(alertList, host, valueType)
        if(curr_alert_index != -1):
            print("old alert")
            print(alertList[curr_alert_index].getTime())
            print(alertList[curr_alert_index].getCounter())
            curr_alert = alertList[curr_alert_index]
            curr_alert.updateAlert(value)
            shouldSend = curr_alert.getFlag()
            alertList[curr_alert_index] = curr_alert
            if(shouldSend):
                sendAlerts(alertList)
        else:
            print("new alert")
            new_alert = alert(host, valueType, 1, curr_avg)
            new_alert.updateAlert(value)
            shouldSend = new_alert.getFlag()
            alertList.append(new_alert)
            if(shouldSend):
                sendAlerts(alertList)
    else:
        curr_alert_index = findAlert(alertList, host, valueType)
        if(curr_alert_index != -1):
            curr_alert = alertList[curr_alert_index]
            curr_alert.updateTime()
            alertList[curr_alert_index] = curr_alert
        else:
            new_alert = alert(host, valueType, 0, curr_avg)
            alertList.append(new_alert)
Example #34
0
	def ButtonRunPressed(self,event):

#start running in full mode ie continuous loop
		
		c = len(liss)
		if not self.textbox4.GetValue():
			error = 10
			aler = alert.alert(None, -1,"ALERT MESSAGE!!!!!!!!!!!!",error)
        		aler.ShowModal()
			return

		self.time_intervel = self.textbox4.GetValue()
		
		for inds in range(c):

			avtms = avtmscorefull.avtmscorefull(liss[inds],self.s,self.time_intervel)
			avtms.start()
Example #35
0
	def ButtonRunhalfPressed(self,event):

#Start working in half mode 
		c = len(liss)
		if not self.textbox4.GetValue():

			error = 10
			aler = alert.alert(None, -1,"ALERT MESSAGE!!!!!!!!!!!!",error)
        		aler.ShowModal()
        		return

		else:

			self.time_intervel = self.textbox4.GetValue()

		for inds in range(c):

			avtms1= avtmscorehalf.avtmscorehalf(liss[inds],self.s,self.time_intervel)
			avtms1.start()
Example #36
0
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " + str(e)

        timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp, self.TIMEZONE)

        for entity in feed.entity:
            # Trip update represents a change in timetable
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()

                ##### INSERT TRIPUPDATE CODE HERE ####
                update.tripId = entity.trip_update.trip.trip_id
                update.routeId = entity.trip_update.trip.route_id
                update.startDate = entity.trip_update.trip.start_date
                update.direction = entity.trip_update.trip.trip_id[10]
                update.futureStop[
                    entity.trip_update.stop_time_update.stop_id] = [
                        entity.trip_update.stop_time_update.arrival.time,
                        entity.trip_update.stop_time_update.departure.time
                    ]

            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                ##### INSERT VEHICLE CODE HERE #####
                v.currentStopNumber = entity.vehicle.current_stop_sequence
                v.currentStopId = entity.vehicle.stop_id
                v.timestamp = entity.vehicle.timestamp
                v.currentStopStatus = entity.vehicle.current_status

            if entity.alert:
                a = alert.alert()
                #### INSERT ALERT CODE HERE #####
                alert.tripId = entity.alert.informed_entity.trip.trip_id
                alert.routeId = entity.alert.informed_entity.trip.route_id
                alert.startDate = entity.trip_update.trip.start_date

        return self.tripUpdates
Example #37
0
def threshold(metric_name, image, message):
    
    receiver = raw_input('Reciever\' Username [%s]' % getpass.getuser())
    sender = raw_input('\nSender\' Username [%s]' % getpass.getuser())
    print ('Enter password for Username %s' % sender)
    pwd = getpass.getpass()

    header = '''
    Alerts of METRIC = {}:

        '''.format(metric_name)
    
    message = header + message
                
    trigger = alert.alert(sender, receiver, pwd, message, image)
            
    try:
        trigger.mailing()
    except Exception, err:
        print err
Example #38
0
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " +str(e)

        timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp,self.TIMEZONE)

        for entity in feed.entity:
            # Trip update represents a change in timetable
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()
                ##### INSERT TRIPUPDATE CODE HERE ####
                header_time = feed.header.timestamp
                update.tripId = entity.trip_update.trip.trip_id
                update.routeId = entity.trip_update.trip.route_id
                update.startDate = entity.trip_update.trip.start_date
                directionId = update.tripId.rfind('.')
                directionInt = int(directionId)

                update.direction = update.tripId[int(directionInt+1):int(directionInt+2)]
                update.time = header_time
                update.futureStops = OrderedDict()

                for stop in entity.trip_update.stop_time_update:
                    stopId = stop.stop_id
                    stopInfo = OrderedDict()
                    stopInfo['arrivalTime'] = stop.arrival.time
                    stopInfo['departureTime'] = stop.departure.time
                    stopInfo['arrivalTime'] = stop.arrival.time
                    stopInfo['departureTime'] = stop.departure.time
                    update.futureStops[stopId] = stopInfo
                    #print "check1"
                self.tripUpdates.append(update)
                    #print self.tripUpdates

            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                ##### INSERT VEHICLE CODE HERE #####
                header_time_v = entity.vehicle.timestamp
                v.currentStopNumber = entity.vehicle.current_stop_sequence
                v.currentStopId = entity.vehicle.stop_id
                v.timestamp = header_time_v
                v.currentStopStatus = entity.vehicle.current_status

                for trip in self.tripUpdates:
                    if trip.tripId == entity.vehicle.trip.trip_id:
                        trip.vehicleData = v
                        #print "check2"

            if entity.alert:
                a = alert.alert()
                #### INSERT ALERT CODE HERE #####
                if entity.alert and entity.alert.header_text and entity.alert.header_text.translation and hasattr(entity.alert.header_text.translation,'text'):
                    a.alertMessage = entity.alert.header_text.translation.text
                if entity.alert and entity.alert.informed_entity and hasattr(entity.alert.informed_entity,'trip'):
                    if hasattr(entity.alert.informed_entity.trip,'trip_id'):
                        a.tripId = entity.alert.informed_entity.trip.trip_id
                        for tripUpdate in self.tripUpdates:
                            if tripUpdate.tripId == entity.alert.informed_entity.trip.trip_id:
                                a.startDate = tripUpdate.startDate
                    if entity.alert.informed_entity.trip.route_id:
                        a.routeId = entity.alert.informed_entity.trip.route_id
                        #print "check3"

                self.alerts.append(a)

        return self.tripUpdates
Example #39
0
 def input_cookie(self):
     alert("SCRAWLER-RENREN","Input a New Cookie")
     new_cookie=raw_input("#### input new a cookie ####\n") 
     self.set_cookie(new_cookie)
     self.export_cookie()
Example #40
0
def eye_protect():
    alert("友情提示", "40分钟了,起来溜达溜达吧!")
__author__ = 'vxst'
import alert

alert.alert("Test dist", "Test message")
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " +str(e)
	

	timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp,self.TIMEZONE)
	
	for entity in feed.entity:
	    # Trip update represents a change in timetable
	    if entity.trip_update and entity.trip_update.trip.trip_id:
		update = tripupdate.tripupdate()
		update.tripId = entity.trip_update.trip.trip_id
		update.routeId = entity.trip_update.trip.route_id
		update.startDate = entity.trip_update.trip.start_date
		# We can get direction from tripId
		update.direction = update.tripId[10]
		
		# Route id could be 1,2,3,4,5,6 or S.
                # However for S they use  GS
                if update.routeId == 'GS':
                    update.routeId = 'S'
		
		# Create an ordered dictionary
		for stopUpdate in entity.trip_update.stop_time_update:
		    arrivalTime = {"arrivalTime" : stopUpdate.arrival.time}
		    departureTime = {"departureTime" : stopUpdate.departure.time}    
		    update.futureStops[stopUpdate.stop_id] = [arrivalTime, departureTime]
		
		
		self.tripUpdates.append(update)

	    if entity.vehicle and entity.vehicle.trip.trip_id:
	    	v = vehicle.vehicle()
		vehicleData = entity.vehicle
		tripId = vehicleData.trip.trip_id
		v.currentStopNumber = vehicleData.current_stop_sequence
		v.currentStopId = vehicleData.stop_id
		v.timestamp   =  vehicleData.timestamp
		if not vehicleData.current_status:
		    v.currentStopStatus = self.VCS[1]
		else:
		    v.currentStopStatus = self.VCS[vehicleData.current_status]
		# Find the tripUpdate object with the exact tripId
	    	tripUpdateObject = next((trip for trip in self.tripUpdates if trip.tripId == tripId), None)
		tripUpdateObject.vehicleData = v
	    
	    if entity.alert:
                a = alert.alert()
		for item in entity.alert.informed_entity:
		    trip = item.trip.trip_id
                    a.tripId.append(trip)
                    a.routeId[trip] = item.trip.route_id  
		a.alertMessage = entity.alert.header_text
		self.alerts.append(a)

	return self.tripUpdates
Example #43
0
expected = {
    provider: set.union(*map(vpss_from_cm, provider_dcs))
    for provider, provider_dcs in dcs.iteritems()
}

actual = {
    provider: set(v.name for v in vps_util.vps_shell(provider).all_vpss()
                  if not v.name.startswith('fp-')
                  or vps_util.is_production_proxy(v.name))
    for provider in dcs
}

errors = []
for provider in dcs:
    for caption, vpss in [(("Missing %s droplets" % provider.upper()),
                           expected[provider] - actual[provider]),
                          (("Unexpected %s droplets" % provider.upper()),
                           actual[provider] - expected[provider])]:
        if vpss:
            errors.append(caption + ": " + ", ".join(sorted(vpss)))

if errors:
    for error in errors:
        print "ERROR: ", error
    alert(type='vps-list-mismatch',
          details={'errors': errors},
          title='Mismatch in VPS list',
          text="".join(error + "\n" for error in errors))
else:
    print "No errors."
def trataJson(*args):
    try:
        #Estações principais

        #Números da estações: 25541|25891|31105|31101|31109|25503|31515|25499|31107|32451|25549|3968|25891|25541|31095|25525|31111|27843|25551|31091|31099|31115|25531|31089|13609|12364|39077

        #13609 não tem temperatura

        #define url
        url = 'https://www.purpleair.com/json?key=IQWSYIVV2FJCFHX6&show=25541|25891|31105|31101|31109|25503|31515|25499|31107|32451|25549|3968|25891|25541|31095|25525|31111|27843|25551|31091|31099|31115|25531|31089|12364|39077|13609'
        #Requisitando link
        r = requests.get(url)
        #Criando um arquivo json
        files = r.json()

        #Criando arquivo final com apenas os resultados
        datafinal = files.get("results")

        print(datafinal[0]["ID"])

        print(str(datafinal[0]["ID"]) + str(datafinal[0]["LastSeen"]))

        print("_____________")
        print("_____________")

        log()
        for i in range(0, len(datafinal), 2):
            #Conecção com o banco
            engine = create_engine(
                'postgresql://*****:*****@localhost:5432/cemaden_pa')
            conn = engine.connect()
            #Inserção no banco
            result = conn.execute(
                "INSERT INTO cemaden (idsensor,chave,Label,lat,lon, PM2_5Value,temp_f,humidity,pressure,p_0_3_um,p_0_5_um,p_1_0_um,p_2_5_um,p_5_0_um,p_10_0_um,pm1_0_cf_1,pm2_5_cf_1,pm10_0_cf_1,pm1_0_atm,pm2_5_atm,pm10_0_atm,LastSeen,LastUpdateCheck,Type) VALUES ({},'{}','{}',{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},'{}')"
                .format(datafinal[i]["ID"], str(uuid.uuid4()),
                        datafinal[i]["Label"], datafinal[i]["Lat"],
                        datafinal[i]["Lon"], datafinal[i]["PM2_5Value"],
                        datafinal[i].get("temp_f", "NULL"), datafinal[i].get(
                            "humidity",
                            "NULL"), datafinal[i].get("pressure", "NULL"),
                        datafinal[i]["p_0_3_um"], datafinal[i]["p_0_5_um"],
                        datafinal[i]["p_1_0_um"], datafinal[i]["p_2_5_um"],
                        datafinal[i]["p_5_0_um"], datafinal[i]["p_10_0_um"],
                        datafinal[i]["pm1_0_cf_1"], datafinal[i]["pm2_5_cf_1"],
                        datafinal[i]["pm10_0_cf_1"], datafinal[i]["pm1_0_atm"],
                        datafinal[i]["pm2_5_atm"], datafinal[i]["pm10_0_atm"],
                        datafinal[i]["LastSeen"],
                        datafinal[i]["LastUpdateCheck"], datafinal[i]["Type"]))
            #Encerrando conecção
            conn.close()

        #Estações secundárias

        #Números da estações: 25542|25893|31106|31102|31110|25504|31516|25500|31108|32452|25550|3969|25893|25542|31096|25525|31112|27844|25552|31092|31100|31116|25532|31090|13610|12365|39078

        #define url - 1 sensor
        url1 = 'https://www.purpleair.com/json?key=09SJEDDKBLPK75M6&show=25542|25893|31106|31102|31110|25504|31516|25500|31108|32452|25550|3969|25893|25542|31096|25525|31112|27844|25552|31092|31100|31116|25532|31090|13610|12365|39078'
        #Requisitando link
        r1 = requests.get(url1)
        files1 = r1.json()

        #Criando arquivo final com apenas os resultados
        datafinal2 = files1.get("results")

        for i in range(0, len(datafinal2), 1):
            #Conecção com o banco
            engine = create_engine(
                'postgresql://*****:*****@localhost:5432/cemaden_pa')
            conn = engine.connect()
            #inserção no banco
            result = conn.execute(
                "INSERT INTO cemaden (idsensor,chave,Label,lat,lon, PM2_5Value,p_0_3_um,p_0_5_um,p_1_0_um,p_2_5_um,p_5_0_um,p_10_0_um,pm1_0_cf_1,pm2_5_cf_1,pm10_0_cf_1,pm1_0_atm,pm2_5_atm,pm10_0_atm,LastSeen) VALUES ({},'{}','{}',{},{},{},'{}',{},{},{},{},{},{},{},{},{},{},{},{})"
                .format(
                    datafinal2[i]["ID"], str(uuid.uuid4()),
                    datafinal2[i]["Label"], datafinal2[i]["Lat"],
                    datafinal2[i]["Lon"], datafinal2[i]["PM2_5Value"],
                    datafinal2[i]["p_0_3_um"], datafinal2[i]["p_0_5_um"],
                    datafinal2[i]["p_1_0_um"], datafinal2[i]["p_2_5_um"],
                    datafinal2[i]["p_5_0_um"], datafinal2[i]["p_10_0_um"],
                    datafinal2[i]["pm1_0_cf_1"], datafinal2[i]["pm2_5_cf_1"],
                    datafinal2[i]["pm10_0_cf_1"], datafinal2[i]["pm1_0_atm"],
                    datafinal2[i]["pm2_5_atm"], datafinal2[i]["pm10_0_atm"],
                    datafinal2[i]["LastSeen"]))
            #Encerrando conecção
            conn.close()

    except Exception as e:
        print(e)
        logerro()
        alert()
Example #45
0
#!/var/www/sites/live/bin/python
import subprocess
import re

def check(path):
	proc = subprocess.Popen(['df', path], stdout=subprocess.PIPE, 
										  stderr=subprocess.PIPE)
	proc.stdout.readline()
	line = proc.stdout.read()
	used = int(re.search(r'(\d+)%', line).groups(1)[0])

	proc.stdout.read()
	proc.stderr.read()
	return used

if __name__ == '__main__':
	import alert

	if check('/var/opt/media') > 70:
		alert.alert('Disk usage at '+str(used)+'%!', '')
Example #46
0
    def __init__(self,lasagna,parent=None):

        super(plugin,self).__init__(lasagna) #This calls the lasagna_plugin constructor which in turn calls subsequent constructors        

        #Is the Elastix binary in the system path?
        if which('elastix') is None:
            #TODO: does not stop properly. Have to uncheck and recheck the plugin menu item to get it to run a second time.
            from alert import alert
            self.alert=alert(lasagna,'The elastix binary does not appear to be in your path.<br>Not starting plugin.')
            self.lasagna.pluginActions[self.__module__].setChecked(False) #Uncheck the menu item associated with this plugin's name
            self.deleteLater()
            return
        else:
            print "Using elastix binary at " + which('elastix')


        #re-define some default properties that were originally defined in lasagna_plugin
        self.pluginShortName='Elastix' #Appears on the menu
        self.pluginLongName='registration of images' #Can be used for other purposes (e.g. tool-tip)
        self.pluginAuthor='Rob Campbell'

        #This is the file name we monitor during running
        self.elastixLogName='elastix.log'


        #Create widgets defined in the designer file
        self.setupUi(self)
        self.show()


        #The dictionary which will store the command components
        #the param files and output are separate as they are stored in the list view and ouput path text edit box
        self.elastix_cmd = {
                        'f': '',   #fixed image
                        'm' : ''   #moving image
                        }

        #A dictionary for storing location of temporary parameter files
        #Temporary parameter files are created as the user edits them and are 
        #removed when the registration starts
        self.tmpParamFiles = {}


 

        #Create some properties which we will need
        self.fixedStackPath = '' #absolute path to reference image
        self.movingStackPath = '' #absolute path to sample image


        #Set up the list view on Tab 2
        self.paramItemModel = QtGui.QStandardItemModel(self.paramListView)
        self.paramListView.setModel(self.paramItemModel)
  
        #Link signals to slots
        #Tab 1 - Loading data
        self.loadFixed.released.connect(self.loadFixed_slot)
        self.loadMoving.released.connect(self.loadMoving_slot)
        self.originalMovingImage = None #The original moving image is stored here
        self.originalMovingFname = None 

        #Flip axis 
        self.flipAxis1.released.connect(lambda: self.flipAxis_Slot(0))
        self.flipAxis2.released.connect(lambda: self.flipAxis_Slot(1))
        self.flipAxis3.released.connect(lambda: self.flipAxis_Slot(2))

        #Rotate axis 
        self.rotAxis1.released.connect(lambda: self.rotAxis_Slot(0))
        self.rotAxis2.released.connect(lambda: self.rotAxis_Slot(1))
        self.rotAxis3.released.connect(lambda: self.rotAxis_Slot(2))

        #Swap axes
        self.swapAxis1_2.released.connect(lambda: self.swapAxis_Slot(0,1))
        self.swapAxis2_3.released.connect(lambda: self.swapAxis_Slot(1,2))
        self.swapAxis3_1.released.connect(lambda: self.swapAxis_Slot(2,0))

        self.saveModifiedMovingStack.released.connect(self.saveModifiedMovingStack_slot)

        #Tab 2 - Building the registration command 
        self.outputDirSelect_button.released.connect(self.selectOutputDir_slot)
        self.removeParameter.released.connect(self.removeParameter_slot)
        self.loadParamFile.released.connect(self.loadParamFile_slot)
        self.moveParamUp_button.released.connect(self.moveParamUp_button_slot)
        self.moveParamDown_button.released.connect(self.moveParamDown_button_slot)


        #Tab 3 - parameter file
        self.plainTextEditParam.textChanged.connect(self.plainTextEditParam_slot)
        self.comboBoxParam.activated.connect(self.comboBoxParamLoadOnSelect_slot)


        #Tab 4: running
        self.runElastix_button.released.connect(self.runElastix_button_slot)
        self.runElastix_button.setEnabled(False)
        #Start a QTimer to poll for finished analyses
        self.finishedMonitorTimer = QtCore.QTimer()
        self.finishedMonitorTimer.timeout.connect(self.analysisFinished_slot)
        self.finishedMonitorTimer.start(2500) #Number of milliseconds between poll events
        self.listofDirectoriesWithRunningAnalyses = [] 
        #Set up list view on the running tab
        self.runningAnalysesItemModel = QtGui.QStandardItemModel(self.runningRegistrations_ListView)
        self.runningRegistrations_ListView.setModel(self.runningAnalysesItemModel)


        #Tab 5: results
        self.resultsItemModel = QtGui.QStandardItemModel(self.registrationResults_ListView)
        self.registrationResults_ListView.setModel(self.resultsItemModel)
        self.registrationResults_ListView.clicked.connect(self.resultImageClicked_Slot)
        self.resultImages_Dict={} #the keys are result image file names and the values are the result images
        self.showHighlightedResult_radioButton.toggled.connect(self.overlayRadioButtons_Slot)
        self.showOriginalMovingImage_radioButton.toggled.connect(self.overlayRadioButtons_Slot)


        #Clear all image stacks 
        self.lasagna.removeIngredientByType('imagestack')

        #-------------------------------------------------------------------------------------
        #The following will either be hugely changed or deleted when the plugin is no longer
        #under heavy development
        debug=False #runs certain things quickly to help development
        if debug and os.path.expanduser("~")=='/home/rob' : #Ensure only I can trigger this. Ensures that it doesn't activate if I accidently push with debug enabled
         
            self.fixedStackPath='/mnt/data/TissueCyte/registrationTests/regPipelinePrototype/YH84_150507_target.mhd'
            self.movingStackPath='/mnt/data/TissueCyte/registrationTests/regPipelinePrototype/YH84_150507_moving.mhd'

            doRealLoad=True
            if doRealLoad:
                self.loadFixed_slot(self.fixedStackPath)                
                self.loadMoving_slot(self.movingStackPath)
                self.lasagna.initialiseAxes()

            doParamFile=True
            if doParamFile:
                #load param file list
                paramFiles = ['/mnt/data/TissueCyte/registrationTests/regPipelinePrototype/Par0000affine.txt',
                              '/mnt/data/TissueCyte/registrationTests/regPipelinePrototype/Par0000bspline.txt']
                paramFiles = ['/mnt/data/TissueCyte/registrationTests/regPipelinePrototype/Par0000affine_quick.txt']
                self.loadParamFile_slot(paramFiles)

            self.outputDir_label.setText(self.absToRelPath('/mnt/data/TissueCyte/registrationTests/regPipelinePrototype/reg2'))
            self.updateWidgets_slot()
            self.tabWidget.setCurrentIndex(3)
Example #47
0
       'vl': ['vltok1', 'vlfra1', 'vlpar1'],
       'li': ['lisgp1', 'litok1']}

expected = {provider: set.union(*map(vpss_from_cm, provider_dcs))
            for provider, provider_dcs in dcs.iteritems()}

actual = {provider: set(v.name
                        for v in vps_util.vps_shell(provider).all_vpss()
                        if not v.name.startswith('fp-')
                        or vps_util.is_production_proxy(v.name))
          for provider in dcs}

errors = []
for provider in dcs:
    for caption, vpss in [(("Missing %s droplets" % provider.upper()),
                           expected[provider] - actual[provider]),
                          (("Unexpected %s droplets" % provider.upper()),
                           actual[provider] - expected[provider])]:
        if vpss:
            errors.append(caption + ": " + ", ".join(sorted(vpss)))

if errors:
    for error in errors:
        print "ERROR: ", error
    alert(type='vps-list-mismatch',
          details={'errors': errors},
          title='Mismatch in VPS list',
          text="".join(error + "\n" for error in errors))
else:
    print "No errors."
Example #48
0
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " +str(e)

        timestamp = feed.header.timestamp
	#print type(timestamp)
        nytime = datetime.fromtimestamp(timestamp,self.TIMEZONE)

        trips={}

        for entity in feed.entity:
            # print entity
            # Trip update represents a change in timetable
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()
                ##### INSERT TRIPUPDATE CODE HERE ####
                update.tripId = str(entity.trip_update.trip.trip_id)
		#print str(update.tripId)[-4]
                update.routeId = entity.trip_update.trip.route_id
                update.startDate = entity.trip_update.trip.start_date
		st = update.tripId
                if st.split('.')[1] == '':
			update.direction = st.split('.')[2][0]
                else:
         		update.direction = st.split('.')[1][0]
		#print update.direction
		#print entity.trip_update.trip.direction_id
                if entity.trip_update.vehicle:
                      update.vehicleData = entity.trip_update.vehicle
                tmp = collections.OrderedDict()
                len_stop = len(entity.trip_update.stop_time_update)
                for i in range(len_stop):
            	    #print entity.trip_update.stop_time_update[i].stop_id
		    #print entity.trip_update.stop_time_update[i].arrival.time
 		    #print entity.trip_update.stop_time_update[i].departure.time
                    tmp[str(entity.trip_update.stop_time_update[i].stop_id)] = [
                        entity.trip_update.stop_time_update[i].arrival.time,
                        entity.trip_update.stop_time_update[i].departure.time
                    ]
		#print tmp.items()
		#tmp = collections.OrderedDict()
                update.futureStops = str(tmp.items())
		#print update.futureStops

                if update.tripId not in trips.keys():
                    trips[update.tripId] = ini()
                trips[update.tripId]['routeId'] = update.routeId
                trips[update.tripId]['startDate'] = update.startDate
                trips[update.tripId]['direction'] = update.direction
                trips[update.tripId]['futureStopData'] = update.futureStops
		trips[update.tripId]['timeStamp'] =  timestamp
                
		#print 'tripId: ',update.tripId, 
	        #print 'routeId: ',update.routeId, 
                #print 'startDate: ',update.startDate

            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                ##### INSERT VEHICLE CODE HERE #####
                v.currentStopNumber = entity.vehicle.current_stop_sequence
                v.currentStopId = entity.vehicle.stop_id
                v.timestamp = entity.vehicle.timestamp
                v.currentStopStatus = self.VCS[int(entity.vehicle.current_status)+1]
                #print v.currentStopNumber, v.currentStopId, 
		#print v.currentStopStatus
                if entity.vehicle.trip.trip_id not in trips.keys():
                    trips[entity.vehicle.trip.trip_id] = ini()
                trips[entity.vehicle.trip.trip_id]['currentStopId'] = v.currentStopNumber
                trips[entity.vehicle.trip.trip_id]['currentStopStatus'] = v.currentStopStatus
                trips[entity.vehicle.trip.trip_id]['vehicleTimeStamp'] = v.timestamp
                trips[entity.vehicle.trip.trip_id]['timeStamp']= timestamp
		
            if entity.alert:
                a = alert.alert()
                #### INSERT ALERT CODE HERE #####
                a.alertMessage = []
                mes_len = len(entity.alert.header_text.translation)
                for i in range(mes_len):
                    a.alertMessage.append(entity.alert.header_text.translation[i].text)
                a.tripId = []
		trip_len = len(entity.alert.informed_entity)
                for i in range(trip_len):
                     a.tripId.append(entity.alert.informed_entity[i].trip.trip_id)
                     a.routeId[entity.alert.informed_entity[i].trip.trip_id] = entity.alert.informed_entity[i].trip.route_id
                     if entity.alert.informed_entity[i].trip.start_date:
		                  a.startDate[entity.alert.informed_entity[i].trip.trip_id] = entity.alert.informed_entity[i].trip.start_date
                self.alerts.append(a)
		
        #print trips
        self.tripUpdates.append(trips) 
	return self.tripUpdates
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib.request.urlopen(
                    self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except:
            print('connection error')
            # return "ERROR"
        '''
        except (urllib.error.URLError, google.protobuf.message.DecodeError) as e:\
            print ("Error while connecting to mta server " +str(e))'''
        timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp, self.TIMEZONE)

        self.tripUpdates = []
        for entity in feed.entity:
            # Trip update represents a change in timetable
            duplicate = 0
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()
                update.tripId = str(entity.trip_update.trip.trip_id)
                update.routeId = str(entity.trip_update.trip.route_id)
                update.startDate = str(entity.trip_update.trip.start_date)
                update.direction = 'N' if 'N' in update.tripId else 'S'
                if entity.trip_update.stop_time_update:
                    for stop_update in entity.trip_update.stop_time_update:
                        arrival_time = stop_update.arrival.time if stop_update.HasField(
                            'arrival') else ' '
                        departure_time = stop_update.departure.time if stop_update.HasField(
                            'departure') else ' '
                        update.futureStops[str(stop_update.stop_id)] = [{
                            "arrivalTime":
                            arrival_time
                        }, {
                            "departureTime":
                            departure_time
                        }]
                for tripUpdate in self.tripUpdates:
                    if tripUpdate.tripId == update.tripId:
                        duplicate = 1
                        tripUpdate.futureStops = update.futureStops
                if duplicate == 0:
                    self.tripUpdates.append(update)

            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                v.currentStopSequence = str(
                    entity.vehicle.current_stop_sequence)
                v.currentStopId = str(entity.vehicle.stop_id)
                v.currentStopStatus = str(entity.vehicle.current_status)
                v.timestamp = entity.vehicle.timestamp
                for tripUpdate in self.tripUpdates:
                    if tripUpdate.tripId == str(entity.vehicle.trip.trip_id):
                        tripUpdate.vehicleData = v
                        duplicate = 1
                if duplicate == 0:
                    update = tripupdate.tripupdate()
                    update.tripId = str(entity.vehicle.trip.trip_id)
                    update.routeId = str(entity.vehicle.trip.route_id)
                    update.startDate = str(entity.vehicle.trip.start_date)
                    update.direction = 'N' if 'N' in update.tripId else 'S'
                    update.vehicleData = v
                    self.tripUpdates.append(update)
            if entity.alert:
                a = alert.alert()
        return [self.tripUpdates, timestamp]
Example #50
0
prefix = 'fallbacks-to-check'
try:
    local_version = file(prefix + '-version').read()
except IOError:
    local_version = None
remote_version = redis_shell.get('srvcount')
if local_version != remote_version:
    suppress = redis_shell.smembers('checkfallbacks-suppress')
    json.dump([yaml.load(cfg).values()[0]
               for srv, cfg in redis_shell.hgetall('srv->cfg').iteritems()
               if srv not in suppress],
              file(prefix + '.json', 'w'))
    file(prefix + '-version', 'w').write(remote_version)

cmd = subprocess.Popen("checkfallbacks -fallbacks %s.json -connections 20 | grep '\[failed fallback check\]'" % prefix,
                       shell=True,
                       stdout=subprocess.PIPE)
errors = list(cmd.stdout)
if errors:
    for error in errors:
        print error
    alert(type='checkfallbacks-failures',
          details={'errors': errors},
          title='Proxy check failures',
          text="".join(error[len('[failed fallback check] '):] + "\n"
                       for error in errors),
          color="#dddd77")
else:
    print "No errors."
def check(re_str, url):
    rep = requests.get(url)
    text = rep.text
    match = re.compile(re_str)
    if match.findall(text):
        alert("情友提示", "mysql的python3.5驱动出来了!")
Example #52
0
 def input_cookie(self):
     alert("SCRAWLER-RENREN", "Input a New Cookie")
     new_cookie = raw_input("#### input new a cookie ####\n")
     self.set_cookie(new_cookie)
     self.export_cookie()
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " + str(e)

        timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp, self.TIMEZONE)

        for entity in feed.entity:
            # Trip update represents a change in timetable
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()
                update.tripId = entity.trip_update.trip.trip_id
                update.routeId = entity.trip_update.trip.route_id
                update.startDate = entity.trip_update.trip.start_date
                # We can get direction from tripId
                update.direction = update.tripId[10]

                # Route id could be 1,2,3,4,5,6 or S.
                # However for S they use  GS
                if update.routeId == 'GS':
                    update.routeId = 'S'

                # Create an ordered dictionary
                for stopUpdate in entity.trip_update.stop_time_update:
                    arrivalTime = {"arrivalTime": stopUpdate.arrival.time}
                    departureTime = {
                        "departureTime": stopUpdate.departure.time
                    }
                    update.futureStops[stopUpdate.stop_id] = [
                        arrivalTime, departureTime
                    ]

                self.tripUpdates.append(update)

            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                vehicleData = entity.vehicle
                tripId = vehicleData.trip.trip_id
                v.currentStopNumber = vehicleData.current_stop_sequence
                v.currentStopId = vehicleData.stop_id
                v.timestamp = vehicleData.timestamp
                if not vehicleData.current_status:
                    v.currentStopStatus = self.VCS[1]
                else:
                    v.currentStopStatus = self.VCS[vehicleData.current_status]

# Find the tripUpdate object with the exact tripId
                tripUpdateObject = next(
                    (trip
                     for trip in self.tripUpdates if trip.tripId == tripId),
                    None)
                tripUpdateObject.vehicleData = v

            if entity.alert:
                a = alert.alert()
                for item in entity.alert.informed_entity:
                    trip = item.trip.trip_id
                    a.tripId.append(trip)
                    a.routeId[trip] = item.trip.route_id
                a.alertMessage = entity.alert.header_text
                self.alerts.append(a)

        return self.tripUpdates
Example #54
0
    def __init__(self,lasagna,parent=None):

        super(plugin,self).__init__(lasagna) #This calls the lasagna_plugin constructor which in turn calls subsequent constructors        

        #Is the Transformix (or Elastix) binary in the system path?
        #We search for both in case we in the future add the ability to calculate inverse transforms and other good stuff
        if which('transformix') is None or which('elastix') is None:
            #TODO: does it stop properly? Will we have to uncheck and recheck the plugin menu item to get it to run a second time?
            from alert import alert
            self.alert=alert(lasagna,'The elastix or transformix binaries do not appear to be in your path.<br>Not starting plugin.')
            self.lasagna.pluginActions[self.__module__].setChecked(False) #Uncheck the menu item associated with this plugin's name
            self.deleteLater()
            return
        else:
            print "Using transformix binary at " + which('transformix')
            print "Using elastix binary at " + which('elastix')


        #re-define some default properties that were originally defined in lasagna_plugin
        self.pluginShortName='Transformix' #Appears on the menu
        self.pluginLongName='registration of images' #Can be used for other purposes (e.g. tool-tip)
        self.pluginAuthor='Rob Campbell'

        #This is the file name we monitor during running
        self.elastixLogName='elastix.log'
        self.transformixLogName='transformix.log'
        self.transformixCommand = '' #the command we will run

        #Create widgets defined in the designer file
        self.setupUi(self)
        self.show()

        #A dictionary for storing location of temporary parameter files
        #Temporary parameter files are created as the user edits them and are 
        #removed when the registration starts
        self.tmpParamFiles = {}

        #Create some properties which we will need
        self.inputImagePath = '' #absolute path to the image we will transform
        self.transformPath = '' #absolute path to the tranform file we will use
        self.outputDirPath = ''
        self.transformixCommand = ''


        #Link signals to slots
        self.chooseStack_pushButton.released.connect(self.chooseStack_slot)
        self.chooseTransform_pushButton.released.connect(self.chooseTransform_slot)
        self.outputDirSelect_pushButton.released.connect(self.selectOutputDir_slot)

        self.run_pushButton.released.connect(self.run_slot)
        self.loadResult_pushButton.released.connect(self.loadResult_slot)
        

        #Disable UI elements that won't be available until the user has completed all actions
        self.run_pushButton.setEnabled(False)
        self.loadResult_pushButton.setEnabled(False)

        #-------------------------------------------------------------------------------------
        #The following will either be hugely changed or deleted when the plugin is no longer
        #under heavy development
        debug=False #runs certain things quickly to help development
        if debug and os.path.expanduser("~")=='/home/rob' : #Ensure only I can trigger this. Ensures that it doesn't activate if I accidently push with debug enabled
  
            self.inputImagePath = '' #absolute path to the image we will transform
            self.transformPath = '' #absolute path to the tranform file we will use
Example #55
0
from time import sleep
from alert import alert

t = 60  #sleeping time in secs
while True:
    alert()
    sleep(t)
Example #56
0
_, _, lavg = os.getloadavg()

print "Starting with load average %s..." % lavg

# Allow us to override any of the above locally in some machines. For example,
# we may not want fallback proxies to retire themselves even if they're
# overloaded.
try:
    from check_load_overrides import *
except ImportError:
    pass

if lavg > report_threshold:
    print "report threshold surpassed; notifying..."
    alert(type='high-proxy-load',
          details={'load-avg': lavg},
          title='High load in proxy',
          text="Load average %s" % lavg)

# We don't want to retire servers in the surge that made us close them, because
# load usually eases after closing and we want to give it a chance to
# stabilize. So we check whether at least one day has elapsed since we closed
# the server before we retire it because of load.
#
# We do this here, and not in util.py, because that module is used by the
# traffic checks too, and this reasoning doesn't apply to that case: once a
# server has consumed too much traffic there's no point in waiting before
# retiring it.
try:
    s = file(util.close_flag_filename).read()
    t0 = datetime.strptime(s, '%Y-%m-%d %H:%M:%S.%f')
    closed_long_ago = (datetime.utcnow() - t0).days > 1
Example #57
0
    def __init__(self, lasagna, parent=None):

        super(plugin, self).__init__(
            lasagna
        )  #This calls the lasagna_plugin constructor which in turn calls subsequent constructors

        #Is the Transformix (or Elastix) binary in the system path?
        #We search for both in case we in the future add the ability to calculate inverse transforms and other good stuff
        if which('transformix') is None or which('elastix') is None:
            #TODO: does it stop properly? Will we have to uncheck and recheck the plugin menu item to get it to run a second time?
            from alert import alert
            self.alert = alert(
                lasagna,
                'The elastix or transformix binaries do not appear to be in your path.<br>Not starting plugin.'
            )
            self.lasagna.pluginActions[self.__module__].setChecked(
                False
            )  #Uncheck the menu item associated with this plugin's name
            self.deleteLater()
            return
        else:
            print("Using transformix binary at " + which('transformix'))
            print("Using elastix binary at " + which('elastix'))

        #re-define some default properties that were originally defined in lasagna_plugin
        self.pluginShortName = 'Transformix'  #Appears on the menu
        self.pluginLongName = 'registration of images'  #Can be used for other purposes (e.g. tool-tip)
        self.pluginAuthor = 'Rob Campbell'

        #This is the file name we monitor during running
        self.elastixLogName = 'elastix.log'
        self.transformixLogName = 'transformix.log'
        self.transformixCommand = ''  #the command we will run

        #Create widgets defined in the designer file
        self.setupUi(self)
        self.show()

        #A dictionary for storing location of temporary parameter files
        #Temporary parameter files are created as the user edits them and are
        #removed when the registration starts
        self.tmpParamFiles = {}

        #Create some properties which we will need
        self.inputImagePath = ''  #absolute path to the image we will transform
        self.transformPath = ''  #absolute path to the tranform file we will use
        self.outputDirPath = ''
        self.transformixCommand = ''

        #Link signals to slots
        self.chooseStack_pushButton.released.connect(self.chooseStack_slot)
        self.chooseTransform_pushButton.released.connect(
            self.chooseTransform_slot)
        self.outputDirSelect_pushButton.released.connect(
            self.selectOutputDir_slot)

        self.run_pushButton.released.connect(self.run_slot)
        self.loadResult_pushButton.released.connect(self.loadResult_slot)

        #Disable UI elements that won't be available until the user has completed all actions
        self.run_pushButton.setEnabled(False)
        self.loadResult_pushButton.setEnabled(False)

        #-------------------------------------------------------------------------------------
        #The following will either be hugely changed or deleted when the plugin is no longer
        #under heavy development
        debug = False  #runs certain things quickly to help development
        if debug and os.path.expanduser(
                "~"
        ) == '/home/rob':  #Ensure only I can trigger this. Ensures that it doesn't activate if I accidently push with debug enabled

            self.inputImagePath = ''  #absolute path to the image we will transform
            self.transformPath = ''  #absolute path to the tranform file we will use
    def getTripUpdates(self):
        feed = gtfs_realtime_pb2.FeedMessage()
        #print type(time)
	try:
            with contextlib.closing(urllib2.urlopen(self.feedurl)) as response:
                d = feed.ParseFromString(response.read())
        except (urllib2.URLError, google.protobuf.message.DecodeError) as e:
            print "Error while connecting to mta server " +str(e)
    

        timestamp = feed.header.timestamp
        nytime = datetime.fromtimestamp(timestamp,self.TIMEZONE)
        tripUpdates = []
	uList = []
        vList = []
    	aList = []
        for entity in feed.entity:
            # Trip update represents a change in timetable
            
            if entity.trip_update and entity.trip_update.trip.trip_id:
                update = tripupdate.tripupdate()
                update.tripId = entity.trip_update.trip.trip_id
                update.routeId = entity.trip_update.trip.route_id
                update.startDate = entity.trip_update.trip.start_date
                tripId = entity.trip_update.trip.trip_id
                
                update.direction = tripId[tripId.rfind('.')+1]# n/s  parse from trip id

                #update.vehicleData = None

                d = OrderedDict()
                for stop in entity.trip_update.stop_time_update:
                    arrivalDict = {}
		    departDict = {}
		    arrive = None
                    depart = None
            
                    arrive = stop.arrival.time
                    depart = stop.departure.time

                    arrivalDict["arrival_time"] = arrive
		    departDict["depart_time"] = depart
		    d[stop.stop_id] = [arrivalDict, departDict]
                update.futureStops = d # Format {stopId : [arrivalTime,departureTime]}
                
                uList.append(update)            
            ##### INSERT TRIPUPDATE CODE HERE ####          

            if entity.vehicle and entity.vehicle.trip.trip_id:
                v = vehicle.vehicle()
                v.currentStopNumber = entity.vehicle.current_stop_sequence
                v.currentStopId = entity.vehicle.stop_id
                v.timestamp = entity.vehicle.timestamp
                v.currentStopStatus = entity.vehicle.current_status
                v.tripId = entity.vehicle.trip.trip_id
                vList.append(v)
            ##### INSERT VEHICLE CODE HERE #####
            if entity.alert:
                a = alert.alert()
        if hasattr(entity.alert, 'trip'):
                    a.tripId = entity.alert.trip.trip_id
                    a.routeId = entity.alert.trip.route_id
                    a.startDate = entity.alert.trip.start_date
                    a.alertMessage = entity.alert.header_text.translation           
            #### INSERT ALERT CODE HERE #####
        
        tripUpdates.append(uList)
        tripUpdates.append(vList)
        tripUpdates.append(aList)
        tripUpdates.append(timestamp)
        return tripUpdates