Beispiel #1
0
def create_config():
 c = ConfManager(name)
 c.add_section("world", "&World Settings")
 c.set("world", "name", "Untitled", title = "&Name", validate = lambda value: None if value else "Every world must have a name.")
 c.set("world", "host", "", title = "&Hostname")
 c.set("world", "port", 23, title = "&Port", kwargs = dict(min = 1, max = 65535), validate = lambda value: None if value > 0 and value < 65535 else "Port numbers must be between 1 and 65535.")
 c.add_section("application", "&Application Settings")
 c.set("application", "command_char", "/", title = "Internal &commands must start with")
 c.set("application", "command_sep", ";", title = "Commands are separated with")
 c.set("application", "encoding", "ascii", title = "Lines should be encoded and decoded using (only change if you know what you\re doing)")
 c.set("application", "print_colours", False, title = "&Print colour tags")
 c.set('application', 'copy_after', 0.5, title = 'Copy reviewed text to &clipboard after', kwargs = dict(min_val = 0.1, digits = 2))
 c.set("application", "gag_blank", True, title = "&Gag blank lines")
 c.set("application", "print_commands", True, title = "&Print commands to the output window")
 c.set('application', 'command_interval', 0.0, title = 'The &interval between commands being sent', kwargs = dict(digits = 2, min_val = 0.0))
 c.add_section("sound", "&Sound Settings")
 c.set("sound", "volume", 0.7, title = "&Volume", kwargs = dict(min_val = 0.0, max_val = 1.0, digits = 2))
 c.set("sound", "pan", 0.0, title = "&Pan", kwargs = dict(min_val = -1.0, max_val = 1.0, digits = 2))
 c.set("sound", "frequency", 44100.0, title = "&Frequency", kwargs = dict(min_val = 100.0, max_val = 100000.0, digits = 2))
 return c
Beispiel #2
0
import numpy as np
from confmanager import ConfManager

setproctitle.setproctitle("rangefinder")

GPIO.setmode(GPIO.BCM)  #setup for PWM
GPIO.setup(20, GPIO.OUT)  #Define pin 20 as output
maxbotix = serial.Serial(
    "/dev/ttyAMA0", baudrate=9600, timeout=5
)  #Open a serial input to recieve from the maxbotix ultrasonic sensor
time.sleep(
    0.2
)  #This sleep interval is required to let the serial input open completely before it is read for the first time. Without this pause, random crashes on startup occur
timesinceflip = 0

config = ConfManager()

print config.ConfigVibrationEnabled
print config.ConfigVibrateSoundEnabled

p = pyaudio.PyAudio()

volume = 0.2  # Range 0.0 - 1.0
fs = 44100  #Audio Sampling Rate
duration = 0.5  #Duration in seconds, may be float
f = 440  #Sine Frequency, Hz, may be float
#Generate Samples, Not Conversion to float32 array
samples = (np.sin(2 * np.pi * np.arange(fs * duration) * f / fs)).astype(
    np.float32)

#for paFloat32 sample values must be in range -1.0 = 1.0
 def read(self):
     """Read configuration file"""
     ConfManager.read(self)
     self.read_login_data()
     self.read_cloud_conf()
 def __init__(self):
     ConfManager.__init__(self, 'nimbus')
     self.cloud_parser = SafeConfigParser()
        )):  #This is required for the keyscanning to use the USB number pad
    printLock.acquire()
    print "Close: " + k
    printLock.release()
    if k == "c":  #While debugging. If you press 'c' once, you can now use ctrl c to terminate the execution
        keys.stopCapture()


t1 = 0  #t1-t4 used for timing pushbutton events
t2 = 0  # t2-t4 used as adders amongst a few intervals to allow for assignments of different functions based on time the button is depressed
t3 = 0  #
t4 = 0  #The final interval of 7 seconds shuts the device down (software, not electricity). It protects the filesystem and ought to remain

timesinceflip = 0

config = ConfManager()  # Load our class with settings from aftersight.cfg

vibration = False  #By default vibration is turned off

if config.ConfigVibrationStartup:  #If the config file sets rangefinder/vibration for startup, toggle the variable for the vibration motor
    vibration = True

A_Pin = 4  #Encoder CC direction
B_Pin = 5  #Enconder C direction
encoder = gaugette.rotary_encoder.RotaryEncoder.Worker(
    A_Pin, B_Pin)  #Use worker class to try to catch transitions better.
encoder.start()  #start the worker class encoder watcher
encoder.steps_per_cycle = 4  #the encoder always gives 4 for 1 detente

oldexternalpowerstate = 0  # this variable enables an espeak event when the power plug is inserted or removed
Beispiel #6
0
from confmanager import ConfManager, parser
import application, wx, functions

config = ConfManager(application.name + ' Options')

config.add_section('login')
config.set('login', 'uid', '', title = 'The email address to log in with')
config.set('login', 'pwd', '', 'The password to log in with (stored in plain text)', kwargs = {'style': wx.TE_PASSWORD})
config.set('login', 'remember', False, title = 'Remember credentials across restarts')

config.add_section('library')
config.set('library', 'library_size', 1024, title = 'The size of the library in megabytes before the oldest tracks are deleted')
config.set('library', 'max_top_tracks', 50, title = 'The max top tracks to retrieve when getting artist info')
config.set('library', 'max_results', 50, title = 'Maximum results to display')
config.set('library', 'history_length', 5, title = 'The number of previous results to save')
config.set('library', 'download_timeout', 15.0, title = 'The time to wait before retrying a download.', kwargs = dict(digits = 1))
config.set('library', 'cache', True, title = '&Cache songs in the background')
config.set('library', 'media_directory', '', title = 'Library &Location')

config.add_section('windows')
config.set('windows', 'load_library', True, title = 'Load the music library when the program starts')
config.set('windows', 'title_format', u'{artist} - {title}', title = 'The format for track names (possible formatters: {albumArtRef}, {artistId}, {composer}, {trackType}, {id}, {album}, {title}, {creationTimestamp}, {recentTimestamp}, {albumArtist}, {trackNumber}, {discNumber}, {contentType}, {deleted}, {storeId}, {nid}, {estimatedSize}, {albumId}, {genre}, {playCount}, {artistArtRef}, {kind}, {artist}, {lastModifiedTimestamp}, {durationMillis})')
config.set('windows', 'now_playing_format', u'({pos} / {duration}): {title}', title = 'The format for the status display in the now playing field')
config.set('windows', 'confirm_quit', False, title = 'Confirm before quitting the program')
config.set('windows', 'play_controls_show', True, title = 'Show player controls')
config.set('windows', 'uid_label', '&Username', title = 'The label for the username field')
config.set('windows', 'pwd_label', '&Password', title = 'The label for the password field')
config.set('windows', 'remember_label', '&Store my password in plain text', title = 'The label for the remember password checkbox')
config.set('windows', 'login_label', '&Login', title = 'The label for the login button')
config.set('windows', 'ok_label', '&OK', title = 'The label for OK buttons')
config.set('windows', 'cancel_label', '&Cancel', title = 'The label for cancel buttons')
Beispiel #7
0
import wx
from confmanager import ConfManager

"""Set up some example stuff, so you can get a working example of the classes in action:"""
if __name__ == '__main__':
 a = wx.App() # Create the main wx app
 c = ConfManager('test') # Make a ConfManager and call it test
 c.add_section('people') # Add a section called people
 # Add some options:
 c.set('people', 'name', 'John Smith', title = 'Customer &Name', validate = lambda value: None if len(value) >= 4 else 'No one is name is that short!', help = 'The name of the customer')
 c.set('people', 'age', 43, title = 'Customer &Age', validate = lambda value: None if (value > 18 and value <= 120) else 'Sorry, but we don\'t have babies or dead people on our books.', help = 'The age of the customer')
 c.set('people', 'height', 0, title = 'Customer &Height', validate = lambda value: None if value >= 100 else 'I don\'t like small types!', help = 'The height of the customer in centemeters')
 c.add_section('likes', 'Likes and Dislikes')
 c.set('likes', 'chocolate', False, title = 'Lovely Milky &Chocolate', help = 'You know what chocolate is')
 c.set('likes', 'jam', True, title = '&Jam (Any Flavour You Like)', help = 'My mum makes the best jam')
 c.add_section('misc', 'Miscelaneous')
 c.set('misc', 'about', '', kwargs = {'style': wx.TE_RICH|wx.TE_MULTILINE})
 import wx.lib.filebrowsebutton as FBB
 import os
 c.set('misc', 'file', '', title = 'Upload a &file', control = FBB.FileBrowseButton, validate = lambda value: None if os.path.exists(value) else 'You must provide a file to load!')
 c.helpFunc = lambda event: wx.MessageBox('This is a test page.\n\nFor updates to this library, please visit github.com/chrisnorman7/confmanager.git', 'Help')
 c.get_gui().Show(True) # Show the resulting GUI
 a.MainLoop() # Run the mainloop to ensure a proper application
 def __init__(self):
     ConfManager.__init__(self, 'openstack')
     self.cloud_parser = SafeConfigParser()
Beispiel #9
0
def CheckToClose(k, (keys, printLock)): #This is required for the keyscanning to use the USB number pad
    printLock.acquire()
    print "Close: " + k
    printLock.release()
    if k == "c":                        #While debugging. If you press 'c' once, you can now use ctrl c to terminate the execution
        keys.stopCapture()

t1=0 #t1-t4 used for timing pushbutton events
t2=0 # t2-t4 used as adders amongst a few intervals to allow for assignments of different functions based on time the button is depressed
t3=0 #
t4=0 #The final interval of 7 seconds shuts the device down (software, not electricity). It protects the filesystem and ought to remain

timesinceflip = 0

config = ConfManager() # Load our class with settings from aftersight.cfg

vibration = False #By default vibration is turned off

if config.ConfigVibrationStartup: #If the config file sets rangefinder/vibration for startup, toggle the variable for the vibration motor
        vibration = True

A_Pin=4 #Encoder CC direction
B_Pin=5 #Enconder C direction
encoder = gaugette.rotary_encoder.RotaryEncoder.Worker(A_Pin, B_Pin)#Use worker class to try to catch transitions better.
encoder.start()#start the worker class encoder watcher
encoder.steps_per_cycle = 4 #the encoder always gives 4 for 1 detente

oldexternalpowerstate = 0 # this variable enables an espeak event when the power plug is inserted or removed

Main=["Toggle Raspivoice","Toggle Teradeep","Toggle Distance Sensor","Toggle Face Detection", "Settings","acknowledgements","Disclaimer"]
 def __init__(self):
     ConfManager.__init__(self, 'ruleengine')
     self.cloud_parser = SafeConfigParser()
 def __init__(self):
     ConfManager.__init__(self, "eucalyptus")
     self.cloud_parser = SafeConfigParser()