コード例 #1
0
def get_previous_session():
    sess = None
    token_key, token_secret = config.get_access_token()

    if token_key and token_secret:
        sess = session.DropboxSession(config.get_key(), config.get_secret(), ACCESS_TYPE)
        sess.set_token(token_key, token_secret)

    return sess
コード例 #2
0
def create_new_session():
    sess = session.DropboxSession(config.get_key(), config.get_secret(), ACCESS_TYPE)
    request_token = sess.obtain_request_token()

    print((sess.build_authorize_url(request_token)))
    print("Visit this website and press the 'Allow' button, then hit 'Enter' here: ")

    raw_input()

    access_token = sess.obtain_access_token(request_token)
    config.save_access_token(access_token.key, access_token.secret)

    return sess
コード例 #3
0
ファイル: sig.py プロジェクト: willfraser/prophecy
def hash():

    #    url = "https://api.heroku.com/apps/frozen-garden-83591/config-vars"
    #    r = requests.get(url)
    #    values = r.json()

    key = config.get_key()
    secret = config.get_secret()
    clientID = config.get_clientID()

    nonce = int(time.time() * 1000000) + 374491605044

    message = str(nonce) + clientID + key
    message = bytes(message, 'utf-8')
    byte_key = bytes(secret, 'utf-8')

    signature = hmac.new(byte_key, message, hashlib.sha256).hexdigest()

    return ({"key": key, "signature": str.lower(signature), "nonce": nonce})
コード例 #4
0
from sendmail import sendalert
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient

config = config.Config()
config_rules = rules_config.Config()
script_path = "/usr/local/infodes/azure/env/azure/bin/python "\
              "/usr/local/infodes/bin/{}".format(os.path.basename(__file__))

host_name = socket.gethostname()
host_ip_public = get('http://ifconfig.co/ip').text.rstrip('\n')

subscription_id = config.get_subscription_id()
credentials = ServicePrincipalCredentials(client_id=config.get_client_id(),
                                          secret=config.get_secret(),
                                          tenant=config.get_tenant())

compute_client = ComputeManagementClient(credentials, subscription_id)
network_client = NetworkManagementClient(credentials, subscription_id)


def update_rules(rules_element, rules_group):

    ip_list = []

    for keys, values in rules_element.items():
        if values not in ip_list:
            ip_list.append(values)

    if ip_list:
コード例 #5
0
from flask_restx import Api
from flask_restx import Resource
from flask import request  # change
from orderlist import *
from json import dumps
from flask_cors import CORS, cross_origin
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.ext.flask.middleware import XRayMiddleware

app = Flask(__name__)
api = Api(app)
CORS(app, resources={r'*': {'origins': '*'}})
xray_recorder.configure(service='flask-orderlist-restapi')
XRayMiddleware(app, xray_recorder)

config.get_secret()
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://{}:{}@{}/{}'.format(
    os.getenv('DB_USER', config.DATABASE_CONFIG['DB_USER']),
    os.getenv('DB_PASSWORD', config.DATABASE_CONFIG['DB_PASSWORD']),
    os.getenv('DB_HOST', config.DATABASE_CONFIG['DB_HOST']),
    os.getenv('DB_NAME', config.DATABASE_CONFIG['DB_NAME']))

db = SQLAlchemy(app)


@api.route('/orderlists')
class OrderListIndex(Resource):
    def get(self):
        ret = []
        res = db.session.query(OrderList).all()
        for orderlist in res: