def show_tables(): """ creates a report for specified month """ month = request.args.get('month', '') year = request.args.get('year', '') day = request.args.get('day', '') if not month or not year: abort(400) start = date(year=int(year), month=int(month), day=int(day)) r = Report(start=start, finished=False) r.put() assetid = request.args.get('assetid', '') month = request.args.get('fmonth', '') year = request.args.get('fyear', '') day = request.args.get('fday', '') if assetid and month and year and day: r.end = date(year=int(year), month=int(month), day=int(day)) r.assetid = assetid r.finished = True r.put() deferred.defer(update_report_stats, str(r.key())) return r.as_json()
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() self.login('*****@*****.**', 'testuser') # generate data for reports self.r = Report(start=date(year=2011, month=2, day=1), end=date(year=2011, month=3, day=1), finished=True) self.r.put() stats = { 'id': str(self.r.key()), 'stats': { '0000_01': { 'id': '01', 'table': '0000', 'def': 1, 'deg': 2 }, '0000_02': { 'id': '02', 'table': '0000', 'def': 1, 'deg': 2 }, '0001_02': { 'id': '02', 'table': '0001', 'def': 1, 'deg': 2 } } } StatsStore(report_id=str(self.r.key()), json=json.dumps(stats)).put()
def setUp(self): # create resources self.polygon = [[[-63.154907226557498, -4.8118385341739005], [-64.143676757807498, -4.8118385341739005], [-64.132690429682498, -6.2879986723276584], [-62.814331054682498, -6.3535159310087908]]] self.inv_polygon = [[[y, x] for x, y in self.polygon[0]]] self.r = Report(start=date(year=2011, month=2, day=1), end=date(year=2011, month=3, day=1), finished=True) self.r.put() self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put() self.area = Area(geo=json.dumps(self.inv_polygon), added_by=None, type=1, cell=self.cell) self.area.put() self.area.create_fusion_tables() self.ndfi = NDFI(self.r.comparation_range(), self.r.range()) self.stats = Stats()
def setUp(self): r = Report(start=date.today(), finished=False) r.put() self.r = r self.cell = Cell(x=11, y=11, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put()
def setUp(self): for x in models.CELL_BLACK_LIST[:]: models.CELL_BLACK_LIST.pop() app.config['TESTING'] = True self.login('*****@*****.**', 'testuser') self.app = app.test_client() for x in Cell.all(): x.delete() r = Report(start=date.today(), finished=False) r.put() self.r = r
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() r = Report(start=date.today(), finished=False) r.put() self.r = r self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put() self.area = Area( geo='[[[-61.5,-12],[-61.5,-11],[-60.5,-11],[-60.5,-12]]]', added_by=users.get_current_user(), type=1, cell=self.cell)
def close(self, report_id): """ close current and create new one """ r = Report.get(Key(report_id)) if not r.finished: ndfi = NDFI(r.comparation_range(), r.range()) data = ndfi.freeze_map(r.base_map(), int(settings.FT_TABLE_ID), r.key().id()) logging.info(data) if 'data' not in data: abort(400) data = data['data']['id'] r.close(data) cache_key = NDFIMapApi._cache_key(report_id) memcache.delete(cache_key) # open new report new_report = Report(start=date.today()) new_report.put() return str(new_report.key()) return "already finished"
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() self.login('*****@*****.**', 'testuser') r = Report(start=date.today(), finished=False) r.put() self.r = r self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put() for x in Note.all(): x.delete() self.when = datetime.now() self.note = Note(msg='test msg', added_by=users.get_current_user(), cell=self.cell, added_on=self.when) self.note.put()
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() self.login('*****@*****.**', 'testuser') for x in Area.all(): x.delete() for x in Cell.all(): x.delete() r = Report(start=date.today(), finished=False) r.put() self.r = r self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put() self.area = Area(geo='[]', added_by=users.get_current_user(), type=1, cell=self.cell) self.area.put()
def setUp(self): for x in Report.all(): x.delete() self.r = Report(start=date(year=2011, month=2, day=1), finished=False) self.r.put()