def get_coordinates(self, t):
     try:
         bbl = t[0]
         address = t[1]  # Normalizer.set_address(t[1], bbl)
         lat, lon, full_address = self.geo.search_nominatim(address)
         time.sleep(0.2)
         if lat is None:
             raise ValueError
         num = CsvManager.read_progress() + 1
         CsvManager.write_progress(num)
         return (bbl, t[1], full_address.encode("utf-8"), lon, lat, 1), num
     except ValueError:
         self.error_log.open()
         self.error_log.write(t[1] + ", " + str(t[0]))
         self.error_log.close()
         NominatimGeocode.print_status(" Lat, Long not found ")
         time.sleep(1)
         return -1, False
     except (GeocoderTimedOut, GeocoderServiceError) as e:
         self.error_log.open()
         self.error_log.write(e.message)
         self.error_log.close()
         NominatimGeocode.print_status(e.message)
         time.sleep(1)
         return -2, False
     except KeyboardInterrupt:
         NominatimGeocode.print_status(" Stopped ")
         time.sleep(1)
         return -3, False
 def geocode_process(self, t, geocode):
     re, num = geocode.get_coordinates(t)
     if num:
         CsvManager.append_geo_codes([re], self.output)
         self.progress.update_progress(num)
     else:
         val = CsvManager.read_progress()
         self.progress.update_progress(val+1)
     return re, num
Exemplo n.º 3
0
    def get_coordinates(self, t):
        try:
            bbl = t[0]
            address = t[1]# Normalizer.set_address(t[1], bbl)
            lon, lat, full_address = self.geo.search_dao(address, t[0])
            if lat is None:
                raise ValueError
            TIGERGeocode.print_status(" TIGER")
            num = CsvManager.read_progress()+1
            CsvManager.write_progress(num)
            return (bbl, t[1], full_address.encode('utf-8'), lon, lat, 4), num
        except ValueError:
            self.error_log.open()
            self.error_log.write(t[1]+", "+str(t[0]))
            self.error_log.close()
            TIGERGeocode.print_status(" Lat, Long not found ")
            return -1, False

        except KeyboardInterrupt:
            TIGERGeocode.print_status(" Stopped ")
            return -3, False
 def fix_acris(self):
     tuples = self.preprocess()
     real_estates = []
     while tuples:
         try:
             t = tuples.pop(0)
             bbl = Normalizer.set_bbl(t[0], t[1], t[2])
             address = t[3]+" "+t[4]
             address = Normalizer.set_address(address, bbl)
             date = Normalizer.set_str_to_epoch(t[5])
             price = t[6]
             real_estates.append((bbl, address, date, price))
         except ValueError:
             self.error_log.open()
             self.error_log.write(t[1]+", "+str(t[0]))
             self.error_log.close()
         except KeyboardInterrupt:
             print ""
             print "Stopped"
             CsvManager.append_geo_codes(real_estates, self.output)
     CsvManager.append_geo_codes(real_estates, self.output)
 def preprocess(self):
     tuples = CsvManager.read(self.input)
     num = CsvManager.read_progress()
     print num
     if num == 0:
         CsvManager.write_geo_codes([], self.output)
         CsvManager.write_progress('0')
     self.progress.set_size(len(tuples))
     self.progress.update_progress(num)
     Normalizer.set_tuple(num, tuples)
     return tuples
Exemplo n.º 6
0
num_rows = worksheet.nrows - 1
curr_row = 29

row = worksheet.row(curr_row)
keys = [x.value for x in row]

players = {'QB': [], 'RB': [], 'WR': [], 'TE': []}

# Collect players
while curr_row < num_rows:
	curr_row += 1
	row = worksheet.row(curr_row)
	row = dict(zip(keys, row))
	if row['Pos'].value == 'PK' or row['Pos'].value == 'ST':
		continue
	player = league.getPlayer(row['Player'].value)
	if player is None:
		continue
	print row
	player.setStat('Pass Yds', row['Y Pa'].value)
	player.setStat('Pass TD', row['TD P'].value)
	player.setStat('Pass Int', row['Int'].value)
	player.setStat('Rush Yards', row['Y Run'].value)
	player.setStat('Rush TD', row['TD Run'].value)
	player.setStat('Rec Yards', row['Y Rec'].value)
	player.setStat('Rec TD', row['TD Rec'].value)
	player.setStat('Ret TD', row['TD Ret'].value)
	
csvManager = CsvManager()

csvManager.printPlayers(league)
# Check if the default directory for logs exists.
try:
    if args.LOG:
        log_directory = os.path.expanduser("~/.ControlProgram")
        if not os.path.exists(log_directory):
            os.makedirs(log_directory)
except Exception, e:
    args.LOG = False
    print "Verbose mode disabled. Error while trying to create log dir:\n%s" % str(e)

app = TaurusApplication([])
app.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))

mainWindow = MainWindow.MainWindow()
ui = MainWindow.Ui_MainWindow()
csvManager = CsvManager(args.CSV, args.GCSV, args.GUI, ui, args.LOG)
ui.setupUi(mainWindow,csvManager)
if args.TITLE:
    mainWindow.setWindowTitle(args.TITLE)

taurusDb = taurus.Database()

device_model = DeviceTreeModel.DeviceTreeModel(ui)
device_model.setDataSource(csvManager)
ui.taurusTreeWidget.setModel(device_model)

device_list_model = DeviceListModel.DeviceListModel(ui)
device_list_model.setDataSource(csvManager)
ui.taurusTreeWidget2.setModel(device_list_model)

agg_system_model = AggSystemTreeModel()
Exemplo n.º 8
0
 def __init__(self, inputdata, outputdata, path):
     self.path = path
     self.input = CsvManager.read(inputdata)
     self.output = outputdata
     self.ts = []
     self.kernels = 1
Exemplo n.º 9
0
 def get_bbls(self):
     bbls_temp = CsvManager.read(self.path)
     bbls = []
     for bbl in bbls_temp:
         bbls.append(int(bbl[0]))
     return bbls
Exemplo n.º 10
0
 def growth(self, kernels=1):
     self.kernels = kernels
     CsvManager.append(self.get_avg_ts(), self.output)
Exemplo n.º 11
0
 def growth(self, sigma):
     CsvManager.append(self.get_avg_ts(sigma), self.output)