def build(self, base_path = ''): '''Generates the href of the button based on the base_path provided.''' # append to the path or update the get params dependent on presence # of opt if self.opt: p = self.request_params.copy() if self.dest: p[self.opt] = self.dest elif self.opt in p: del p[self.opt] else: p = {} base_path = ("%s/%s/" % (base_path, self.dest)).replace('//', '/') self.action_params = p self.bare_path = _force_unicode(base_path.replace('//', '/')).lower() self.bare_path = self.bare_path.rstrip('/') self.base_path = base_path # append the query string base_path += query_string(p) # since we've been sloppy of keeping track of "//", get rid # of any that may be present self.path = base_path.replace('//', '/')
def load_traffic_uncached(interval, what, iden, start_time = None, stop_time = None, npoints = None): """ Fetches pickled traffic from the traffic server and returns it as a list. On connection failure (or no data) returns an empy list. """ def format_date(d): if hasattr(d, "tzinfo"): if d.tzinfo is None: d = d.replace(tzinfo = g.tz) else: d = d.astimezone(g.tz) return ":".join(map(str, d.timetuple()[:6])) traffic_url = os.path.join(g.traffic_url, interval, what, iden) args = {} if start_time: args['start_time'] = format_date(start_time) if stop_time: args['stop_time'] = format_date(stop_time) if npoints: args['n'] = npoints u = urlparse(traffic_url) try: conn = HTTPConnection(u.hostname, u.port) conn.request("GET", u.path + query_string(args)) res = conn.getresponse() res = loads(res.read()) if res.status == 200 else [] conn.close() return res except socket.error: return []
def build(self, base_path=''): '''Generates the href of the button based on the base_path provided.''' # append to the path or update the get params dependent on presence # of opt if self.opt: p = self.request_params.copy() if self.dest: p[self.opt] = self.dest elif self.opt in p: del p[self.opt] else: p = {} base_path = ("%s/%s/" % (base_path, self.dest)).replace('//', '/') self.action_params = p self.bare_path = _force_unicode(base_path.replace('//', '/')).lower() self.bare_path = self.bare_path.rstrip('/') self.base_path = base_path # append the query string base_path += query_string(p) # since we've been sloppy of keeping track of "//", get rid # of any that may be present self.path = base_path.replace('//', '/')
def build(self, base_path=''): '''Generates the href of the button based on the base_path provided.''' if self.style == "external": self.path = self.dest self.bare_path = self.dest return # append to the path or update the get params dependent on presence # of opt if self.opt: p = request.get.copy() p[self.opt] = self.dest else: p = {} base_path = ("%s/%s/" % (base_path, self.dest)).replace('//', '/') p.update(self.dest_params) self.bare_path = _force_unicode(base_path.replace('//', '/')).lower() self.bare_path = self.bare_path.rstrip('/') # append the query string base_path += query_string(p) # since we've been sloppy of keeping track of "//", get rid # of any that may be present self.path = base_path.replace('//', '/')
def build(self, base_path=""): """Generates the href of the button based on the base_path provided.""" if self.style == "external": self.path = self.dest self.bare_path = self.dest return # append to the path or update the get params dependent on presence # of opt if self.opt: p = request.get.copy() p[self.opt] = self.dest else: p = {} base_path = ("%s/%s/" % (base_path, self.dest)).replace("//", "/") p.update(self.dest_params) self.bare_path = _force_unicode(base_path.replace("//", "/")).lower() self.bare_path = self.bare_path.rstrip("/") # append the query string base_path += query_string(p) # since we've been sloppy of keeping track of "//", get rid # of any that may be present self.path = base_path.replace("//", "/")
def load_traffic_uncached(interval, what, iden, start_time = None, stop_time = None, npoints = None): """ Fetches pickled traffic from the traffic server and returns it as a list. On connection failure (or no data) returns an empy list. """ from r2.lib import promote def format_date(d): if hasattr(d, "tzinfo"): if d.tzinfo is None: d = d.replace(tzinfo = g.tz) else: d = d.astimezone(g.tz) return ":".join(map(str, d.timetuple()[:6])) traffic_url = os.path.join(g.traffic_url, interval, what, iden) args = {} if what == 'thing' and interval == 'hour': if start_time: if not isinstance(start_time, datetime.datetime): start_time = datetime.datetime(*start_time.timetuple()[:3]) start_time -= promote.timezone_offset if stop_time: if not isinstance(stop_time, datetime.datetime): stop_time = datetime.datetime(*stop_time.timetuple()[:3]) stop_time -= promote.timezone_offset if start_time: args['start_time'] = format_date(start_time) if stop_time: args['stop_time'] = format_date(stop_time) if npoints: args['n'] = npoints u = urlparse(traffic_url) try: conn = HTTPConnection(u.hostname, u.port) conn.request("GET", u.path + query_string(args)) res = conn.getresponse() res = loads(res.read()) if res.status == 200 else [] conn.close() return res except socket.error: return []
def build(self, base_path = ''): '''Generates the href of the button based on the base_path provided.''' # append to the path or update the get params dependent on presence # of opt if self.opt: p = request.get.copy() p[self.opt] = self.dest else: p = {} base_path = ("%s/%s/" % (base_path, self.dest)).replace('//', '/') self.bare_path = base_path.replace('//', '/') # append the query string base_path += query_string(p) # since we've been sloppy of keeping track of "//", get rid # of any that may be present self.path = base_path.replace('//', '/')
data_df = [] if query == "blockchain": qid = 1 if query == "oracle": qid = 2 if query == "aws": qid = 3 if query == "vaibhav": qid = 4 if MODEL == "true": results = es.search(index=INDEX_NAME, body=ltr_query(query, model_num)) else: results = query_string(es, query, INDEX_NAME) today = datetime.now().date() fileJudgement = {} for result in results['hits']['hits']: source = result['_source'] fields = result['fields'] id = result['_id'] modified_date = datetime.strptime( source['modified_time'].split("T")[0], '%Y-%m-%d').date() daydiff = str((today - modified_date).days) find_no_of_download_query["query"]["match"]["key"] = id # download_res = es.search(index=aggregated_download_logs, body=find_no_of_download_query) # hits = download_res["hits"]["hits"] #