def set_lib_number(self, alias, new): Lib = db.get(alias=alias)[0] Lib.set_number(new) librarian_id = Lib.get_id() lib_id = str(librarian_id) priv_str = str(new) date = get_date() db.insert_log(date + " | " + "Admin set to Librarian(" + lib_id + ") number: " + priv_str)
def remove_document(self, title): if self.get_priv() == 3: db.delete(title) id_str = str(self.get_id()) date = get_date() title_str = str(title) db.insert_log(date + " | Librarian(" + id_str + ") removed Document with title: " + title_str) else: return
def set_outstanding(self, title): if self.get_priv() >= 2: book = db.get(title=title)[0] book.set_outstanding() id_str = str(self.get_id()) date = get_date() title_str = str(title) db.insert_log(date + " | Librarian(" + id_str + ") marked Document " + title_str + " as outstanding") else: return
def new_vp(self, id, alias, name, mail, number, address): if self.get_priv() >= 2: new = VP(id, alias, name, mail, number, address) db.insert(new.summary()) id_str = str(self.get_id()) date = get_date() title_str = str(id) db.insert_log(date + " | Librarian(" + id_str + ") added Visiting Prof. with ID: " + title_str) else: return
def remove(self, id): if self.get_priv() == 3: db.delete(id=id) id_str = str(self.get_id()) date = get_date() us_id_str = str(id) db.insert_log(date + " | Librarian(" + id_str + ") removed user with id: " + us_id_str) else: return
def new_AV_material(self, title, author, value, url, copies): if self.get_priv() >= 2: new = dc.AV_Materials(title, author, value, url, copies=copies) print("avmaterial " + str(new.summary())) db.insert(new.summary()) id_str = str(self.get_id()) date = get_date() title_str = str(title) db.insert_log(date + " | Librarian(" + id_str + ") added AV: " + title_str) else: return
def add_copy_for_doc(self, original: dc.Document, copy_count): if self.get_priv() == 3: original.add_copy(copy_count) db.update(title=original.get_title(), copies=original.get_count_of_copies()) id_str = str(self.get_id()) date = get_date() title_str = str(original.get_title()) db.insert_log(date + " | Librarian(" + id_str + ") added copy for book: " + title_str) else: return
def bundle_installer_dashboard(name, year): if not session.get('logged_in'): flash('Please login.') return redirect(url_for('welcome')) table_name = name+'_'+year+'_bundle_installer_dashboard' key_name = 'bundle_path' model = Model(table_name) column_list = ['bundle_path', 'lv_version', 'lv_api_version', 'toolkit_path', 'safemode', 'actual_size', 'dedupe_size', 'comment'] records = model.select(column_list) records = sorted(records, key=lambda record: record['bundle_path'], reverse=True) for record in records: record['bundle_date'] = get_date(record['bundle_path']) record['bundle_path'] = add_path_prefix(record['bundle_path'], main_config.PATH_PREFIX).rstrip('\\') record['toolkit_date'] = get_date(record['toolkit_path']) record['toolkit_path'] = add_path_prefix(record['toolkit_path'], main_config.PATH_PREFIX).rstrip('\\') return render_template('bundle_installer_dashboard.html', records=records, name=name, year=year, table_name = table_name, key_name = key_name)
def new_article(self, title, author, journal, publication_date, editor, url, copies): if self.get_priv() >= 2: new = dc.Article(title, author, journal, publication_date, editor, url, copies=copies) db.insert(new.summary()) id_str = str(self.get_id()) date = get_date() title_str = str(title) db.insert_log(date + " | Librarian(" + id_str + ") added article: " + title_str) else: return
def remove(self, librarian_id): db.delete(id=librarian_id) id_str = str(librarian_id) date = get_date() db.insert_log(date + " | Admin deleted Librarian with ID: " + id_str)
def estimate_future_price(ticker, seedVelocity, numIterations, startDayMonthYear, endDayMonthYear): velocitySpeed = .3 day, month, year = startDayMonthYear startTime = datetime(day=day, month=month, year=year, hour=9, minute=30) startUTC = timeToUTCMills(startTime) day, month, year = endDayMonthYear endTime = datetime(day=day, month=month, year=year, hour=16) td = endTime - startTime numDays = td.days hours = float(numDays * 6.5) filepath = 'Stocks/' + ticker + '/learnedPatterns2.txt' fileObject = open(filepath, 'r') learnedPatterns = compile_these_patterns(ticker, fileObject) timeInterval = 60 * hours / numIterations avgVol = float(get_quote(ticker)['avgTotalVolume']) numIterationsPerDay = numIterations / numDays iterationVolume = float(avgVol / numIterationsPerDay) for i in range(numIterations): if i == 0: initialSnapshot, quotes = get_snapshot(ticker) initialSnapshot['velocity'] = seedVelocity snapshots = [initialSnapshot] initialSnapshot['time'] = startUTC elif i == 1: secondSnapshot = {} for key in initialSnapshot.keys(): secondSnapshot[key] = initialSnapshot[key] secondSnapshot['time'] = int(secondSnapshot['time']) secondSnapshot['price'] = float(secondSnapshot['price']) secondSnapshot['volume'] = int(secondSnapshot['volume']) secondSnapshot['time'] += (timeInterval * 60000) secondSnapshot['price'] = secondSnapshot['price'] * ( 1 + (secondSnapshot['velocity'] * timeInterval)) secondSnapshot['volume'] += iterationVolume snapshots.append(secondSnapshot) elif i == 2: thirdSnapshot = {} for key in secondSnapshot.keys(): thirdSnapshot[key] = secondSnapshot[key] thirdSnapshot['time'] = int(thirdSnapshot['time']) thirdSnapshot['price'] = float(thirdSnapshot['price']) thirdSnapshot['volume'] = int(thirdSnapshot['volume']) thirdSnapshot['time'] += (timeInterval * 60000) thirdSnapshot['price'] = thirdSnapshot['price'] * ( 1 + (thirdSnapshot['velocity'] * timeInterval)) thirdSnapshot['volume'] += iterationVolume snapshots.append(thirdSnapshot) else: intervals = compile_intervals_from_snapshots(snapshots) states = compile_states_from_intervals(intervals) state = states[-1] estimatedVelocity, usedPatterns = estimate_velocity( state, learnedPatterns) lastSnapshot = snapshots[i - 1] lastVelocity = lastSnapshot['velocity'] lastVolume = lastSnapshot['volume'] lastPrice = lastSnapshot['price'] lastTime = lastSnapshot['time'] newVelocity = lastVelocity * (1 - velocitySpeed) + ( velocitySpeed) * estimatedVelocity newPrice = lastSnapshot['price'] * (1 + newVelocity * timeInterval) randomVolume = -1 while randomVolume < 0: randomVolume = np.random.normal(iterationVolume, iterationVolume / 3, 1) randomVolume = randomVolume[0] newVolume = lastVolume + randomVolume newTime = lastTime + (timeInterval * 60000) newSnapshot = { 'price': newPrice, 'volume': newVolume, 'time': newTime, 'velocity': newVelocity } if get_date(newTime)[3] >= 16: newSnapshot['time'] = newTime + int(17.5 * 60 * 60 * 1000) snapshots.append(newSnapshot) return snapshots[-1]['price']