def checkin_user(): print_xfair_banner() print "Type nothing (and just press enter) to accept the value between the []." print "Press Control-C to start over." kerberos = prompt("Enter your kerberos") default_name, default_major, default_email = fetch_user(kerberos) user = User() user.name = prompt("Enter your name", default=default_name) user.major = prompt("Enter your major(s), comma separated", default=default_major) user.graduation = prompt("Enter your graduation year, or 'Graduate' for grad students") user.email = prompt("Enter your email", default=default_email) return user
def checkin_user(): print_xfair_banner() print "Welcome to the express line!" mit_id = prompt("Please scan the barcode on the back of your MIT ID") if mit_id not in users: print "ERROR: Your MIT ID was not found. Please use the regular check-in lines." time.sleep(4) raise ReferenceError() user = users[mit_id] result = User() result.name = user['name'] result.email = user['email'] result.graduation = user['graduation'] result.major = user['major'] return result
def new_group(self, *args): (response, new_group_name) = prompt(_("New Group"), _("Choose a name for the new group")) if not response: return if new_group_name == "": message = Gtk.MessageDialog(text=_("Cannot create group without a name"), buttons=Gtk.ButtonsType.CLOSE) message.run() message.destroy() elif new_group_name in self.file_handler.get_note_group_names(): message = Gtk.MessageDialog(text=_("Cannot create group: the name %s already exists") % new_group_name, buttons=Gtk.ButtonsType.CLOSE) message.run() message.destroy() else: self.file_handler.new_group(new_group_name) self.change_visible_note_group(new_group_name) self.new_note()
def order_new(self, typ, amount, price=None, protection=True): if amount < D('0.01'): print "Minimum amount is 0.01 %s" % PRODUCT return None if protection == True: if amount > D('100.0'): yesno = prompt("You are about to {0} >100 {1}.".format(typ,PRODUCT),True) if not(yesno): return None amount_int = int(D(amount) * (1/self.bPrec)) params = {"type":str(typ), "amount_int":amount_int } if price: price_int = int(D(price) * (1/self.cPrec)) params["price_int"] = price_int response = self.request(PAIR + "/money/order/add", params, API_VERSION=2) if response["result"] == "success": return response else: return None
def run(): for i, t in enumerate(LEDTYPES): common.prompt(MESSAGE % (i, t)) common.run_project('all_pixel.yml', flag='-t=' + SYNONYMS.get(t, t))
def readhist24(): print "Enter the filename in the data/ directory to open: " filetoopen = raw_input("Leave blank for default: ") if not(filetoopen): filetoopen = "mtgox_entiretrades.txt" with open(os.path.join(partialpath + filetoopen),'r') as f: everything = f.readlines() everything[0],everything[1] = everything[1],everything[0] new = json.loads(everything[0]) newnew = common.floatify(new["data"]) timeframe = raw_input("Press Enter to check the whole file, or just the last 'n' seconds: ") if timeframe: starttime = (newnew[-1]['tid']/1E6) - float(timeframe) templist = [] for a in newnew: if (a['tid']/1E6) > starttime: templist.append(a) newnew = templist [earliesttime],[latesttime] = [[func(x[thing] for x in newnew) for thing in ['tid']] for func in [min,max]] independently = common.prompt("Analyse volume independently as Buys vs. Sells?",True) print "Earliest time is: %s" % (datetime.datetime.fromtimestamp(earliesttime/1E6)) print "Latest time is: %s" % (datetime.datetime.fromtimestamp(latesttime/1E6)) if independently: word = ("BUYS:","SELLS:") loopcount = 2 condition = ("bid","ask") else: word = ["ALL:"] loopcount = 1 condition = ["bidask"] for count in xrange(0,loopcount): print "-"*40 print word[count] print "-"*40 loopcondition = condition[count] #rewritten with list comprehension somehow [lowestprice,lowestamount],[highestprice,highestamount],[totaleachprice,totaleachamount] = \ [[func(x[thing] for x in newnew if x["trade_type"] in loopcondition) for thing in ['price','amount']] for func in [min,max,sum]] tradecount = sum(1 for x in newnew if x["trade_type"] in loopcondition) print "Sum of all prices: $%f & Sum of all amounts: %f BTC" % (totaleachprice, totaleachamount) print "Highest Price: $%f & Lowest Price: $%f" % (highestprice,lowestprice) avgprice = totaleachprice / tradecount avgamt = totaleachamount / tradecount print "Mean Price is $%f and Mean Amount is %f BTC" % (avgprice,avgamt) vwapcum = sum(x['price']*x['amount'] for x in newnew if x["trade_type"] in loopcondition) vwap = vwapcum / totaleachamount print "VWAP is: $%f" % vwap print "Highest Amount: %f BTC & Lowest Amount: %f BTC" % (highestamount,lowestamount) dowhale = common.prompt("Analyse for large transactions?",True) if dowhale: howbig = raw_input("Enter how many BTC above which you want to search for: ") print " List of Whale Transactions (bigger than %s BTC): " % howbig print " ","-"*35 for x in newnew: if x["trade_type"] in loopcondition: if x['amount'] >= int(howbig): time = datetime.datetime.fromtimestamp(x['tid']/1E6).strftime("%H:%M:%S") print "%f BTC @ $%f, %s, %s" % (x['amount'],x['price'],x['properties'],time)