Esempio n. 1
0
from flask import Flask, redirect, session, request, render_template, url_for, flash, jsonify, send_file, make_response
from helpers.s3 import S3
from helpers.constants import Constants
from helpers.githubuser import GithubUser, PublicGithubUser
from helpers.githubbot import GithubBot
from helpers.sources.osenv import OSConstants
from helpers.sources.mongo import MongoConstants
from helpers.extensions import LanguageExtensions
import os, time, datetime

app = Flask(__name__)
dev = os.environ.get('dev') == 'true' or not os.environ.get('PORT')
constants = Constants(OSConstants())
app.secret_key = constants.get('SK')

extensions = LanguageExtensions()

LANGS = dict(zip(constants.get('GH_REPOS').split(','), constants.get('LANGS').split(';')))

try:
  s3 = S3(constants.get('AWS_ACCESS_KEY'), constants.get('AWS_SECRET_KEY'), constants.get('AWS_BUCKET'))
except:
  s3 = None

collections = zip(constants.get('GH_REPOS').split(','), constants.get('STORAGE_COLLECTIONS').split(','))
storages = {}
for repo_name, collection_name in collections:
  try:
    storage = Constants(MongoConstants(collection_name, constants.get('MONGO_URI')))
  except:
    storage = None
Esempio n. 2
0
from flask import Flask, redirect, session, request, render_template, url_for, flash, jsonify, send_file, make_response
from helpers.s3 import S3
from helpers.constants import Constants
from helpers.githubuser import GithubUser, PublicGithubUser
from helpers.githubbot import GithubBot
from helpers.sources.osenv import OSConstants
from helpers.sources.mongo import MongoConstants
from helpers.extensions import LanguageExtensions
import os, time, datetime

app = Flask(__name__)
dev = os.environ.get('dev') == 'true' or not os.environ.get('PORT')
constants = Constants(OSConstants())
app.secret_key = constants.get('SK')

extensions = LanguageExtensions()

LANGS = dict(
    zip(
        constants.get('GH_REPOS').split(','),
        constants.get('LANGS').split(';')))
CURRENT = dict(
    zip(
        constants.get('GH_REPOS').split(','),
        constants.get('CURRENT').split(';')))

try:
    s3 = S3(constants.get('AWS_ACCESS_KEY'), constants.get('AWS_SECRET_KEY'),
            constants.get('AWS_BUCKET'))
except:
    s3 = None
Esempio n. 3
0
from flask import Flask, redirect, session, request, render_template, url_for, flash, jsonify, send_file, make_response
from helpers.s3 import S3
from helpers.constants import Constants
from helpers.githubuser import GithubUser, PublicGithubUser
from helpers.sources.osenv import OSConstants
import os, time, datetime

app = Flask(__name__)
dev = os.environ.get('dev') == 'true' or not os.environ.get('PORT')
constants = Constants(OSConstants())
app.secret_key = constants.get('SK')

try:
  s3 = S3(constants.get('AWS_ACCESS_KEY'), constants.get('AWS_SECRET_KEY'), constants.get('AWS_BUCKET'))
except:
  s3 = None

def valid_object_key(session):
  if session.get('verified') != True:
    return False
  if session.get('valid_paths') is None:
    return False
  for valid_path in session.get('valid_paths'):
    if is_valid_path(session['object_key'], valid_path):
      return True
  return False

def is_valid_path(user_path, valid_path):
  return user_path.startswith(valid_path) or (user_path + "/").startswith(valid_path)

@app.before_request