Example #1
0
def main():
    global username
    if not path.exists("config.ini"):
        setup.initialize()
    else:
        print("Configuration File Found!\n")
        if load_file():
            password = prompt_password()
            scraper.run_scraper(username, password)
            scraper.get_announcements()
            scraper.open_subjects(retrieve_subjects())
        else:
            print("Something went wrong... try deleting 'config.ini' and setup again!")
Example #2
0
def reinitialize():
	db = setup.initialize()
	open(MODIFIED_INTERVIEWS, 'Ub')
	open(MODIFIED_OFFERS, 'Ub')

	#delete tables in case they aready exist
	db.execute('DROP TABLE IF EXISTS INTERVIEWS CASCADE;')
	db.execute('DROP TABLE IF EXISTS OFFERS CASCADE;')

	#create INTERVIEWS and OFFERS table from the csv sources
	db.execute("CREATE table INTERVIEWS (row integer, season integer, jobnum integer, scheduler varchar(200), partnum varchar(200), interviewType VARCHAR(100), interviewDate Date, interviewTime Time, interviewEndTime Time, organization VARCHAR(400), jobtitle	VARCHAR(400), jobtype VARCHAR(400),	function VARCHAR(400), ucid integer, program VARCHAR(200), roundD varchar(200),	industry VARCHAR(200));")
	db.execute("COPY INTERVIEWS FROM \'"+ MODIFIED_INTERVIEWS + "\' DELIMITER ',' CSV;")
	db.execute("CREATE table OFFERS (row integer, season integer, audited varchar(200), jobtypeoffer varchar(200), classyear varchar(200), relationshipmanager varchar(200), industry varchar(200), jobfunction varchar(200), jobfunctionother varchar(200), organization varchar(400), divisionname varchar(200), ucid integer, program varchar(200), programenrolled varchar(200), cohort varchar(200), visastatus varchar(200), citizenship varchar(200), ethnicity varchar(200), undergraduatemajor varchar(200), workexperiencemonths varchar(200), workexperienceyears varchar(200), gender varchar(200), maritalstatus varchar(200), expectedgradquarter varchar(200), graduationdate varchar(200), monthspostgraduationdate varchar(200), offerdate Date, offerstatus varchar(200), decisiondate varchar(200), dateadded varchar(200), internedfororganization varchar(200), jobtitle varchar(200), joboffersource varchar(200), joboffersourceother varchar(200), city varchar(200), state varchar(200), country varchar(200), jobreportingspecialnotes varchar(1000), basesalary varchar(200), basesalarynegotiated varchar(200), reasonfornobasesalary varchar(200), signingstartingbonusamount varchar(200), signingstartingbonuscomment varchar(200), signingstartingbonusnegotiated varchar(200), summerinternshipbonusamount varchar(200), summerinternshipbonuscomment varchar(200), summerinternshipbonusnegotiated varchar(200), earlysignonamount varchar(200), earlysignoncomment varchar(200), earlysignonnegotiated varchar(200), guaranteedyearendamount varchar(200), guaranteedyearendcomment varchar(200), guaranteedyearendnegotiated varchar(200), variableperformanceamount varchar(200), variableperformancecomment varchar(200), variableperformancenegotiated varchar(200), relocationmovingexpensesamount varchar(200), relocationmovingexpensescomment varchar(200), relocationmovingexpensesnegotiat varchar(200), housingamount varchar(200), housingcomment varchar(200), housingnegotiated varchar(200), tuitionreimbursementamount varchar(200), tuitionreimbursementcomment varchar(200), tuitionreimbursementnegotiated varchar(200), stockoptionsamount varchar(200), stockoptionscomment varchar(200), stockoptionsnegotiated varchar(200), profitsharingamount varchar(200), profitsharingcomment varchar(200), profitsharingnegotiated varchar(200), otheramount varchar(200), othercomment varchar(200), othernegotiated varchar(200), startmonthyear varchar(200), internshiplength varchar(200), offerchoice varchar(200), careerchange varchar(200), firstchoicefunction varchar(200), firstchoiceindustry varchar(200), reasoncompensation varchar(200), reasondissatisfaction varchar(200), reasoninternational varchar(200), reasononlyjoboffer varchar(200), reasonpotential varchar(200), reasontraining varchar(200), reasonculture varchar(200), reasonfirmsize varchar(200), reasonlocation varchar(200), reasonpersonal varchar(200), reasonreputation varchar(200), reasontravel varchar(200), reasonother varchar(200), authorizepublishacceptedoffers varchar(200), authorizepublishdeclinedoffers varchar(200), v105 varchar(200), offerlocked varchar(200));")
	db.execute("COPY OFFERS FROM \'" + MODIFIED_OFFERS + "\' DELIMITER ',' CSV;")

	#verify the integrity of the tables with known row lengths
	db.execute("SELECT COUNT(*) FROM INTERVIEWS;")
	results = db.fetchall()[0]
	assert results[0] == 89559
	db.execute("SELECT COUNT(*) FROM OFFERS;")
	results = db.fetchall()[0]
	assert results[0] == 7614
	print "***Constructed NEW INTERVIEWS and NEW OFFERS tables from csv files***\n"

	return db
Example #3
0
def init():
	choice = raw_input("Type the name of the configuration you would like to use with MIDCA, or press enter to customize a new one. Press q to quit. Option setups are located in the setup/option/save directory, and should be referenced without the \".opt\" ending.")
	loading = False
	if choice != "":
		if choice == "q":
			return
		optionSet = options.load_setup(choice)
		if not optionSet:
			print "error loading options"
			return init()
		else:
			optionSet = options.custom_setup(optionSet)
			print "option set loaded successfully."
			loading = True
	else:
		optionSet = options.custom_setup()
	optionSet.ask_all_custom()
	
	#only save if a new custom set was created.
	if not loading:
		saveQ = options.bool_query("Done with customization. Save results?")
		if saveQ:
			name = raw_input("what is the name of this option set?")
			while name == "":
				name = raw_input("what is the name of this option set? Enter q to cancel save.")
			if name != 'q':
				worked = options.save_setup(optionSet, name)
				if worked:
					print "options saved successfully"
				else:
					print "option save failed."
	
	midca = setup.initialize(optionSet)
	return midca
Example #4
0
def init():
    logger.info("Initializing")
    initialize(config)
    move_state(attach_bait)
Example #5
0
#This file generates new interview/offers csvs with the following adjustments:
	1. organization field is replaced with using the map contained within the passed-in input file
	2. "Mock" is eliminated
"""
import setup, csv, sys

"""Constants - CHANGE THESE IF NECSSARY"""
OUTPUTINTERVIEWS = setup.DIR + 'Modified_Interviews.csv'
OUTPUTOFFERS = setup.DIR + 'Modified_Offers.csv'

if len(sys.argv) != 2:
	print "Usage: Python generateNewData.py <organization csv file>"
	sys.exit(-1)

INPUTFILE = setup.DIR + sys.argv[1]
db = setup.initialize()

#Construct a hashmap to map original organizations to corrected organizations
orgMap = {}
reader = csv.DictReader(open(INPUTFILE, 'Urb'), fieldnames = ['original', 'corrected'])
for entry in reader:
	orgMap[entry['original']] = entry['corrected']
print '***Constructed in-memory hashmap to re-write organization names'

writer = csv.DictWriter(open(OUTPUTINTERVIEWS, 'wb'), fieldnames = ['rownum', 'season', 'jobnum', 'schedulenum', 'partnum', 'interviewtype', 'interviewdate', 'interviewstarttime', 'interviewendtime', 'organization', 'jobtitle', 'jobtype', 'function', 'ucid', 'program', 'round', 'industry'])
reader = csv.DictReader(open(setup.INTERVIEWS, 'Ur'), fieldnames = ['rownum', 'season', 'jobnum', 'schedulenum', 'partnum', 'interviewtype', 'interviewdate', 'interviewstarttime', 'interviewendtime', 'organization', 'jobtitle', 'jobtype', 'function', 'ucid', 'program', 'round', 'industry'])
for originalRow in reader:
	#Replace the organization from the original using the orgMap we generated earlier
	newRow = originalRow.copy()
	newRow['organization'] = orgMap[originalRow['organization']]
	newRow['season'] = originalRow['season'][0:4] #Change season to be only the first four characters, which is the year
Example #6
0
    def main(self):
        print("Starting py-lights...")

        self.params = {
            "R": 0,
            "G": 0,
            "B": 0,
            "MAX": 255,
            "Counter": 1,
            "PIN_R": 0,
            "PIN_G": 0,
            "PIN_B": 0
        }

        self.inputLogger = InputLogger()

        self.actions = []
        self.inputs = []

        initialize(self, self.params)

        # initialize gpio
        print("Initializing GPIO")
        pi = pigpio.pi()

        # initialize midi
        print("Initializing MIDI")
        midiin, port_name = midiutil.open_midiinput(1)
        midiin.set_callback(self)

        print("Ready...")
        # Main loop
        while True:
            self.params["Counter"] += 1

            self.params["R"] = 0
            self.params["G"] = 0
            self.params["B"] = 0
            self.params["VISIBILITY"] = 1

            for action in self.actions:
                action.update(self.params)

            for action in self.actions:
                self.params["R"] += action.settings["Color"].r
                self.params["G"] += action.settings["Color"].g
                self.params["B"] += action.settings["Color"].b
                if action.settings["MUTE"] == True:
                    self.params["VISIBILITY"] = 0

            self.params["R"] = min(self.params["R"], self.params["MAX"])
            self.params["G"] = min(self.params["G"], self.params["MAX"])
            self.params["B"] = min(self.params["B"], self.params["MAX"])

            pi.set_PWM_dutycycle(self.params["PIN_R"],
                                 self.params["R"] * self.params["VISIBILITY"])
            pi.set_PWM_dutycycle(self.params["PIN_G"],
                                 self.params["G"] * self.params["VISIBILITY"])
            pi.set_PWM_dutycycle(self.params["PIN_B"],
                                 self.params["B"] * self.params["VISIBILITY"])

            time.sleep(0.01)

        print("Goodbye!")
Example #7
0
    
    # Get shakemap for desired variable, PGA, uncertainty grid and stationdata
    shakemap = ShakeGrid('Inputs/grid.xml', variable = '%s' % voi)
    
    # Uncertainty Data: Units in ln(pctg)
    unc_INTRA = ShakeGrid('Inputs/uncertainty.xml', variable = 'GMPE_INTRA_STD%s' % voi)
    unc_INTER = ShakeGrid('Inputs/uncertainty.xml', variable = 'GMPE_INTER_STD%s' % voi)
    
    # Station Data: Units in pctg
    stationlist = 'Inputs/stationlist.xml'
    stationdata = readStation(stationlist)

    # Initialize the grid
    if my_rank == 0:
        print 'Calling initialize'
    variables = initialize(shakemap, unc_INTRA, unc_INTER, stationdata)
    if my_rank == 0:
        print 'Radius:', radius
        print variables['K'], 'stations', variables['M']*variables['N'], 'data points'
        
    initialization_time = time.time() - total_time_start

    # Compute the random vector
    rand = np.random.randn(variables['N']*variables['M'])

    # Compute the grid, mu, and sigma arrays
    if my_rank == 0:
        print 'Calling main'
    out = main(variables, radius, voi, rand, corr_model, vscorr)
    
    main_time = time.time() - total_time_start - initialization_time
Example #8
0
import time
import network
import machine

from lib.umqttRobust import MQTTClient

import setup
import powerPi

isBroker = True

wlan = network.WLAN(network.STA_IF)
data = setup.initialize()


def sub_cb(topic, msg):
    topic = topic.decode("utf-8")
    charge = msg.decode("utf-8")
    # ex: id/2/0
    _, switch, isCharging = topic.split('/')

    switch = (int) (switch)
    isCharging = (int) (isCharging)
    charge = (int) (charge)
    powerPi.operate(switch, isCharging, charge)

    client.check_msg()


client = MQTTClient(
    client_id = data["client_id"],
Example #9
0
# -*- coding: utf-8 -*-

import os
import setup
setup.initialize()
import logging
import webapp2

from comments import CommentsView

def is_dev_server():
  server_software = os.environ.get('SERVER_SOFTWARE')
  logging.debug(server_software)
  return server_software.startswith('Development')

class MainHandler(webapp2.RequestHandler):
  def get(self):
    self.response.headers['Content-Type'] = 'text/html'
    self.response.out.write('Hello world!')

app = webapp2.WSGIApplication(
    [ ('/comments/([^/]+)', CommentsView) ],
    debug=is_dev_server())
def init():
  print("in init")
  initialize(config)
  move_state(attach_bait)
Example #11
0
 def dispatch(self):
   setup.initialize()
   super(BaseView, self).dispatch()