def _colorize_entries(entries): """ Colorize table <entries> """ data = [] for rank, entry in enumerate(entries): code = entry['code'] price = entry['price'] change_24h = entry['change_24h'] change_1h = entry['change_1h'] cap = entry['cap'] s_spark = spark.spark(entry['spark']) if change_24h != '-': change_24h = colorize_number("%.2f%%" % change_24h) if change_1h != '-': change_1h = colorize_number("%.2f%%" % change_1h) code = colored(code, 'cyan') price = colored(to_precision(price, 6), 'cyan') cap = human_format(cap) data.append( [rank + 1, code, price, change_24h, change_1h, cap, s_spark]) return data
def main(): itap = mydb.Database('itap') select = """ SELECT steps steps , datestamp date, DATE_FORMAT( datestamp , "%Y" ) year , YEARWEEK(datestamp) month , DATE_FORMAT( datestamp , "%a" ) day FROM fitbit_daily ORDER BY datestamp DESC LIMIT 7 """ data = itap.db_array(select) steps = [] reverse = [] for row in data: step = row[0] steps.append(step) reverse.insert(0, step) stepspark = spark.spark(reverse) print stepspark
def main(): itap = mydb.Database( 'itap' ) select = """ SELECT steps steps , datestamp date, DATE_FORMAT( datestamp , "%Y" ) year , YEARWEEK(datestamp) month , DATE_FORMAT( datestamp , "%a" ) day FROM fitbit_daily ORDER BY datestamp DESC LIMIT 7 """ data = itap.db_array(select) steps = [] reverse = [] for row in data: step = row[0] steps.append( step ) reverse.insert( 0 , step ) stepspark = spark.spark( reverse ) print stepspark
def configure(self, env): import params env.set_params(params) spark(env)
def generate_spark(code, number_of_ticks=11): filename = 'data/%s' % code lines = get_last_line(filename, number_of_ticks) vals = [float(x.split()[1]) for x in lines] return spark.spark(vals)
def configure(self, env): import params env.set_params(params) spark(action="config")
def start(self, env): import params env.set_params(params) self.configure(env) spark(action="upload_jar") spark_hs(action="start")