def sendToken(response, title, sender, receiver, data, message): expiration = format(receiver['limit'], "%Y-%m-%d %H:%M:%S") token = jwt.encode( { "client_id": receiver['client_id'], "token_expiration_date": expiration, "data": data, "level": receiver['level'] }, getSecret(), algorithm="HS256").decode('utf8') link = conf.getConf()['web_url'] + "realizacao?token=" + token msg = EmailMessage() msg['Subject'] = title msg['From'] = Address(sender['name'], addr_spec=sender['email']) msg['To'] = Address(receiver['name'], addr_spec=receiver['email']) content = """\ Olá, Há uma prova para você realizar, [3]{0}. Use este link[1] para poder acessar a mesma. Ele irá expirar em [2]{0}! [1]{0} Este é um email automático, não o responda! """ msg.set_content(content.format(link, expiration, message)) asparagus_cid = make_msgid() content = """\ <html> <head></head> <body> <p>Olá,</p> <p>Há uma prova para você realizar, {2}.</br> Use este <a href="{0}">link</a> para poder acessar a mesma. Ele irá expirar em {1}!</p> <p>Este é um email automático, não o responda!</p> </body> </html> """.format(link, expiration, message, asparagus_cid=asparagus_cid[1:-1]) msg.add_alternative(content, subtype='html') try: with smtplib.SMTP(conf.getConf()['smtp_url'], conf.getConf()['smtp_port']) as server: server.starttls() server.login(conf.getConf()['smtp_user'], conf.getConf()['smtp_password']) server.send_message(msg) server.quit() return "" except Exception as e: return errorHandler.handleError(response, e) return ""
def main(): (dbpath,series) = getConf() db = openDb(dbpath) for serie in series: name = serie["name"] serieDb = SerieDb.getFromDb(name, db) if serieDb is None: print "serie " + name + " is None" else: showSeriesStates(serieDb, db) print ""
def main(): (dbpath, series) = getConf() db = openDb(dbpath) for serie in series: name = serie["name"] print "Updating " + name serieDb = SerieDb.getFromDb(name, db) or \ SerieDb.create(serie["name"], serie["feed"], serie["channel"]) updateFromFeed(serieDb, db) saveDb(db)
def getSeriesAsHtml(): (dbpath, series) = getConf() db = openDb(dbpath) ret = "" for serie in series: name = serie["name"] serieDb = SerieDb.getFromDb(name, db) if serieDb is None: ret += "<h2>Serie " + name + " is None</h2>\n" else: ret += "<h2>Serie " + serieDb.name + "</h2>\n" ret += "<ul>\n%s</ul>\n" % showSeriesStates(serieDb, db) return ret
def updateFeedsHtml(): (dbpath, series) = getConf() db = openDb(dbpath) ret = "" for serie in series: name = serie["name"] serieDb = SerieDb.getFromDb(name, db) or \ SerieDb.create(serie["name"], serie["feed"], serie["channel"]) ret += "<p>Updating serie %s from feed %s</p>\n" % (name, serie["feed"]) ret += updateFromFeed(serieDb, db) saveDb(db) return ret
def _load_data(folder, name): basename = folder + name conf = getConf(name) node_labels, classes = util.load_nodes(basename, conf) nNodes = len(node_labels) edges = util.load_edges(basename) nTimeSliceslices = len(edges) if (conf.read_edge_weights): weights = util.load_edge_weights(basename) G_array = [] f = np.zeros((nTimeSliceslices, nNodes)) for i in range(nTimeSliceslices): G = nx.empty_graph(nNodes) edge_weights = [] if (edges[i] != [[None, None]]): for j in range(len(edges[i])): node0 = edges[i][j][0] node1 = edges[i][j][1] if (conf.read_edge_weights): edge_weights.append((node0, node1, weights[i][j])) else: edge_weights.append((node0, node1, 1)) G.add_weighted_edges_from(edge_weights) G_array.append(G) f[i, :] = list(G.degree(weight='weight').values()) xy = json.loads(open('datasets/nodes_' + name + '.json').read())['nodes'] pos = dict() for i in range(nNodes): pos[i] = np.array([xy[i]['x'], xy[i]['y']]) return (G_array, f, pos)
if (datasets_to_run == 'all'): datasets_to_run = [ 'synthetic', 'thiers_2011', 'thiers_2012', 'thiers_2013', 'primary_school', 'hospital', 'imdb1' ] # Rebuild the graph layout rebuild_layout = False folder = 'datasets/' if type(datasets_to_run) is not list: datasets_to_run = [datasets_to_run] for name in datasets_to_run: conf = getConf(name) basename = folder + name ## Loading data from file ## node_labels, classes = util.load_nodes(basename, conf) nNodes = len(node_labels) edges = util.load_edges(basename) nTimeSlices = len(edges) if (conf.read_edge_weights): weights = util.load_edge_weights(basename)
import odoorpc from conf import getConf import re # Prepare the connection to the server db = getConf("RRHH") user = getConf("admin") passw = getConf("admin") url = getConf("http://localhost") port = 8069 protocol = 'jsonrpc' try: m = re.search('(http[s]?)?:?\/?\/?(\S+)', url) if m.group(1): if 'https' in m.group(1): protocol += '+ssl' port = 443 else: port = 80 else: port = 80 url = m.group(2).split(':')[0] try: port = m.group(2).split(':')[1] except Exception as e: print 'No port detected.' except Exception as e: print 'No URL detected: ', str(e) odoo = odoorpc.ODOO(url, protocol=protocol, port=port)