def __init__( self, manager=None, address=DEFAULT_HOSTNAME, port=None, config=None, publickey=None, verbosity=1, logfile=None, mode=None, ): """ network_status, config, publickey loaded from manager if not provided. address and port take system defaults, although without config and publickey, address and port will not be used. """ self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.address = address self.handle_input(manager, mode, port, config, publickey)
def __init__(self, manager=None, verbosity=1, logfile=None, resolution=256 ): self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.manager = manager self.interval = manager.interval self.image = None self.resolution = resolution self.first = True self.start_up() self.conditional = True self.object = None
def __init__(self, manager=None, verbosity=1, logfile=None, resolution=256): self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.manager = manager self.interval = manager.interval self.image = None self.resolution = resolution self.first = True self.start_up() self.conditional = True self.object = None
def handle_input(self, log, logfile, verbosity, interval): """ Sets up logging, verbosity, interval, config, and publickey """ # resolve logging defaults if log and logfile is None: # use default file if logging is enabled logfile = DEFAULT_LOGFILE_D3S if logfile and not log: # enable logging if logfile is specified # (this overrides a log=False input which wouldn't make sense) log = True if log: self.logfile = logfile else: self.logfile = None if verbosity is None: verbosity = 1 self.v = verbosity set_verbosity(self, logfile=logfile) if log: self.vprint(1, '') self.vprint(1, 'Writing to logfile at {}'.format(self.logfile)) self.running = True if interval is None: self.vprint( 2, "No interval given, using interval at 30 seconds") interval = DEFAULT_INTERVAL_NORMAL_D3S self.interval = int(interval)
def __init__(self, manager=None, verbosity=1, logfile=None, resolution=256): """Initiate class variables.""" self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.manager = manager self.interval = manager.interval self.queue = deque() self.maxspectra = manager.maxspectra self.maxspectra = manager.maxspectra self.data = None self.resolution = resolution self.first = True self.waterfall_drawn = False self.colorbar_drawn = True self.disp_count = list() self.time_stamp = list() plt.ion()
def __init__(self, manager=None, verbosity=1, logfile=None, ): self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.manager = manager self.queue = deque('')
def __init__(self, manager=None, verbosity=1, logfile=None, network_led=None, ): self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.manager = manager self.queue = deque('') self.blink_period_s = 1.5 self.led = network_led
def __init__( self, manager=None, verbosity=1, logfile=None, ): self.send_fail = False self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.first_run = True self.manager = manager self.queue = deque('')
def __init__(self, manager=None, verbosity=1, logfile=None, network_led=None, ): self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.manager = manager self.queue = deque('') self.blink_period_s = NETWORK_LED_BLINK_PERIOD_S self.led = network_led
def __init__(self, manager=None, verbosity=1, logfile=None, resolution=256): """ Initiate object """ self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.manager = manager self.interval = manager.interval self.queue = deque() self.maxspectra = manager.maxspectra self.data = None self.resolution = resolution self.first = True self.waterfall_drawn = True # Create a Tkinter window object. window_object = Tkinter.Tk() # Get the full screen width and height. self.screen_width = window_object.winfo_screenwidth() self.screen_height = window_object.winfo_screenheight() # Destroy the Tkinter window object. window_object.destroy() # Start up the plotting windows. self.start_up()
def __init__( self, counts_LED=None, max_accumulation_time_s=DEFAULT_MAX_ACCUM_TIME, use_gpio=None, verbosity=1, logfile=None, ): self.v = verbosity self.logfile = logfile set_verbosity(self, logfile=logfile) if use_gpio is None: self.use_gpio = RPI else: self.use_gpio = use_gpio if not self.use_gpio: self.vprint(1, 'Running Sensor in test mode - no GPIO interrupt') # this "test mode" is not the same as manager.py test mode! # manager test mode runs the sensor normally. # sensor test mode is a software-only construct - no sensor # hardware involved if counts_LED is None: self.vprint(1, 'No LED given for counts; will not flash LED!') self.LED = counts_LED # initialize queue of datetime's self.counts = collections.deque([]) self.accum_time = max_accumulation_time_s if RPI: # use Broadcom GPIO numbering GPIO.setmode(GPIO.BCM) # set up signal pin GPIO.setup(SIGNAL_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) self.add_interrupt()
def __init__(self, manager=None, address=DEFAULT_HOSTNAME, port=None, config=None, publickey=None, verbosity=1, logfile=None, mode=None, ): """ network_status, config, publickey loaded from manager if not provided. address and port take system defaults, although without config and publickey, address and port will not be used. """ self.v = verbosity if manager and logfile is None: set_verbosity(self, logfile=manager.logfile) else: set_verbosity(self, logfile=logfile) self.address = address self.handle_input( manager, mode, port, config, publickey)
def __init__(self, counts_LED=None, max_accumulation_time_s=DEFAULT_MAX_ACCUM_TIME, use_gpio=None, verbosity=1, logfile=None, ): self.v = verbosity self.logfile = logfile set_verbosity(self, logfile=logfile) if use_gpio is None: self.use_gpio = RPI else: self.use_gpio = use_gpio if not self.use_gpio: self.vprint(1, 'Running Sensor in test mode - no GPIO interrupt') # this "test mode" is not the same as manager.py test mode! # manager test mode runs the sensor normally. # sensor test mode is a software-only construct - no sensor # hardware involved if counts_LED is None: self.vprint(1, 'No LED given for counts; will not flash LED!') self.LED = counts_LED # initialize queue of datetime's self.counts = collections.deque([]) self.accum_time = max_accumulation_time_s if RPI: # use Broadcom GPIO numbering GPIO.setmode(GPIO.BCM) # set up signal pin GPIO.setup(SIGNAL_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) self.add_interrupt()
def handle_input(self, log, logfile, verbosity, test, interval, config, publickey, aeskey): if verbosity is None: if test: verbosity = 3 else: verbosity = 1 if self.cirtest: verbosity = 0 self.v = verbosity if log: if logfile is None: if self.sensor_type > 5 or self.sensor_type < 1: print("No sensor running, try running through one of the subclasses to get a proper setup.") self.takedown() for i in range(len(DEFAULT_LOGFILES)): if self.sensor_type == i+1: logfile = DEFAULT_LOGFILES[i] break self.logfile = logfile else: self.logfile = None set_verbosity(self, logfile=logfile) if log: self.vprint(1, '') self.vprint(1, 'Writing to logfile at {}'.format(self.logfile)) self.running = True if self.test: if interval is None: for i in range(len(DEFAULT_TEST_INTERVALS)): if self.sensor_type == i+1: self.vprint( 2, "No interval given, using default for {}".format(TEST_INTERVAL_NAMES[i])) interval = DEFAULT_TEST_INTERVALS[i] break if interval is None: for i in range(len(DEFAULT_INTERVALS)): if self.sensor_type == i+1: self.vprint( 2, "No interval given, using interval at 5 minutes") interval = DEFAULT_INTERVALS[i] break if config is None: self.vprint(2, "No config file given, " + "attempting to use default config path") config = DEFAULT_CONFIG if publickey is None: self.vprint(2, "No publickey file given, " + "attempting to use default publickey path") publickey = DEFAULT_PUBLICKEY if aeskey is None and self.sensor_type == 2: #Only set the AES key when the D3S is being used self.vprint(2, "No AES key file given, " + "attempting to use default AES key path") aeskey = DEFAULT_AESKEY self.interval = interval if config: try: self.config = Config(config, verbosity=self.v, logfile=self.logfile) if self.new_setup == None: self.int_ID = int(self.config.ID) if self.int_ID == 5 or self.int_ID == 29 or self.int_ID == 32 or \ self.int_ID == 33 or self.int_ID >= 39: self.new_setup = True else: self.new_setup = False except IOError: raise IOError( 'Unable to open config file {}!'.format(config)) else: self.vprint( 1, 'WARNING: no config file given. Not posting to server') self.config = None if publickey: try: self.publickey = PublicKey( publickey, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError( 'Unable to load publickey file {}!'.format(publickey)) else: self.vprint( 1, 'WARNING: no public key given. Not posting to server') self.publickey = None if aeskey: try: with open(aeskey, 'r') as aesfile: key = aesfile.read() self.aes = AES.new(key, mode=AES.MODE_ECB) except IOError: raise IOError('Unable to load AES key file {}!'.format( aeskey)) if not aeskey and self.sensor_type == 2: self.vprint( 1, 'WARNING: no AES key given. Not posting to server') self.aes = None if self.sensor_type != 2: self.aes = None
def handle_input(self, log, logfile, verbosity, test, interval, config, publickey): # resolve logging defaults if log and logfile is None: # use default file if logging is enabled logfile = DEFAULT_LOGFILE if logfile and not log: # enable logging if logfile is specified # (this overrides a log=False input which wouldn't make sense) log = True if log: self.logfile = logfile else: self.logfile = None # set up verbosity if verbosity is None: if test: verbosity = 2 else: verbosity = 1 self.v = verbosity set_verbosity(self, logfile=logfile) if log: self.vprint(1, '') self.vprint(1, 'Writing to logfile at {}'.format(self.logfile)) self.test = test self.running = False # resolve defaults that depend on test mode if self.test: if interval is None: self.vprint( 2, "No interval given, using default for TEST MODE") interval = DEFAULT_INTERVAL_TEST else: if interval is None: self.vprint( 2, "No interval given, using default for NORMAL MODE") interval = DEFAULT_INTERVAL_NORMAL if config is None: self.vprint(2, "No config file given, " + "attempting to use default config path") config = DEFAULT_CONFIG if publickey is None: self.vprint(2, "No publickey file given, " + "attempting to use default publickey path") publickey = DEFAULT_PUBLICKEY self.interval = interval if self.datalogflag: self.vprint( 1, 'Writing CPM to data log at {}'.format(self.datalog)) if config: try: self.config = Config(config, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError( 'Unable to open config file {}!'.format(config)) else: self.vprint( 1, 'WARNING: no config file given. Not posting to server') self.config = None if publickey: try: self.publickey = PublicKey( publickey, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError( 'Unable to load publickey file {}!'.format(publickey)) else: self.vprint( 1, 'WARNING: no public key given. Not posting to server') self.publickey = None self.aes = None # gets checked in sender. feature in manager_d3s
def handle_input(self, log, logfile, verbosity, test, interval, config, publickey): if log and logfile is None: logfile = DEFAULT_LOGFILE_AQ if logfile and not log: log = True if log: self.logfile = logfile else: self.logfile = None if verbosity is None: if test: verbosity = 2 else: verbosity = 1 self.v = verbosity set_verbosity(self, logfile=logfile) if log: self.vprint(1, '') self.vprint(1, 'Writing to logfile at {}'.format(self.logfile)) self.running = False if self.test: if interval is None: self.vprint(2, "No interval given, using default for TEST MODE") interval = DEFAULT_INTERVAL_TEST_AQ if interval is None: self.vprint(2, "No interval given, using interval at 5 minutes") interval = DEFAULT_INTERVAL_NORMAL_AQ if config is None: self.vprint( 2, "No config file given, " + "attempting to use default config path") config = DEFAULT_CONFIG if publickey is None: self.vprint( 2, "No publickey file given, " + "attempting to use default publickey path") publickey = DEFAULT_PUBLICKEY self.interval = interval if config: try: self.config = Config(config, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError('Unable to open config file {}!'.format(config)) else: self.vprint( 1, 'WARNING: no config file given. Not posting to server') self.config = None if publickey: try: self.publickey = PublicKey(publickey, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError( 'Unable to load publickey file {}!'.format(publickey)) else: self.vprint(1, 'WARNING: no public key given. Not posting to server') self.publickey = None self.aes = None #checked in sender, used for the manager_d3s
def __init__(self, vlevel=1, logfile=TEST_LOGFILE): try: os.remove(logfile) except OSError: pass auxiliaries.set_verbosity(self, verbosity=vlevel, logfile=logfile)
def __init__(self, vlevel=1): auxiliaries.set_verbosity(self, verbosity=vlevel)
def handle_input(self, log, logfile, verbosity, interval, config, publickey): """ Sets up logging, verbosity, interval, config, and publickey """ # resolve logging defaults if log and logfile is None: # use default file if logging is enabled logfile = DEFAULT_LOGFILE_D3S if logfile and not log: # enable logging if logfile is specified # (this overrides a log=False input which wouldn't make sense) log = True if log: self.logfile = logfile else: self.logfile = None if verbosity is None: verbosity = 1 self.v = verbosity set_verbosity(self, logfile=logfile) if log: self.vprint(1, '') self.vprint(1, 'Writing to logfile at {}'.format(self.logfile)) self.running = True if interval is None: self.vprint( 2, "No interval given, using interval at 30 seconds") interval = DEFAULT_INTERVAL_NORMAL_D3S if config is None: self.vprint(2, "No config file given, " + "attempting to use default config path") config = DEFAULT_CONFIG if publickey is None: self.vprint(2, "No publickey file given, " + "attempting to use default publickey path") publickey = DEFAULT_PUBLICKEY self.interval = interval if config: try: self.config = Config(config, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError( 'Unable to open config file {}!'.format(config)) else: self.vprint( 1, 'WARNING: no config file given. Not posting to server') self.config = None if publickey: try: self.publickey = PublicKey( publickey, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError( 'Unable to load publickey file {}!'.format(publickey)) else: self.vprint( 1, 'WARNING: no public key given. Not posting to server') self.publickey = None
def handle_input(self, log, logfile, verbosity, interval, config, publickey): """ Sets up logging, verbosity, interval, config, and publickey """ # resolve logging defaults if log and logfile is None: # use default file if logging is enabled logfile = DEFAULT_LOGFILE_D3S if logfile and not log: # enable logging if logfile is specified # (this overrides a log=False input which wouldn't make sense) log = True if log: self.logfile = logfile else: self.logfile = None if verbosity is None: verbosity = 1 self.v = verbosity set_verbosity(self, logfile=logfile) if log: self.vprint(1, '') self.vprint(1, 'Writing to logfile at {}'.format(self.logfile)) self.running = True if interval is None: self.vprint(2, "No interval given, using interval at 30 seconds") interval = DEFAULT_INTERVAL_NORMAL_D3S if config is None: self.vprint( 2, "No config file given, " + "attempting to use default config path") config = DEFAULT_CONFIG if publickey is None: self.vprint( 2, "No publickey file given, " + "attempting to use default publickey path") publickey = DEFAULT_PUBLICKEY self.interval = interval if config: try: self.config = Config(config, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError('Unable to open config file {}!'.format(config)) else: self.vprint( 1, 'WARNING: no config file given. Not posting to server') self.config = None if publickey: try: self.publickey = PublicKey(publickey, verbosity=self.v, logfile=self.logfile) except IOError: raise IOError( 'Unable to load publickey file {}!'.format(publickey)) else: self.vprint(1, 'WARNING: no public key given. Not posting to server') self.publickey = None