Exemplo n.º 1
0
 def __init__(self, instance_filename):
     instance = json.loads(fileutil.read_file(instance_filename))
     self.pid = instance["pid"]
     self.address = str(instance["address"])
     self.client = None
     if not pid_exists(self.pid):
         raise Exception("Instance pid is invalid")
Exemplo n.º 2
0
 def load_file(self, path):
     json_str = fileutil.read_file(path)
     if json_str is not None and json_str:
         json_obj = jsontranslator.json_to_object(json_str)
     else:
         raise JsonParseError("File content was empty .")
     self._data = json_obj
Exemplo n.º 3
0
def compile_resource_dict(resdir):
    resdict = {}
    for dirpath, dirnames, filenames in os.walk(resdir):
        for filename in filenames:
            filepath = os.path.join(dirpath, filename)
            respath = os.path.relpath(filepath, resdir)
            sys.stdout.write("Compiling resource: %r\n" % respath)
            resdict[respath] = read_file(filepath)
    return resdict
Exemplo n.º 4
0
#coding:utf-8

import getMem2
import fileutil
from flask import Flask, request, render_template, redirect, session
app = Flask(__name__)

fileutil.read_file()
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'


@app.route('/')
def index():
    if 'username' in session:
        return redirect('/list')
    return render_template('login.html')


@app.route('/loginaction')
def login():
    user = request.args.get('user')
    pwd = request.args.get('pwd')
    erro_msg = ''
    if user and pwd:
        if user == 'admin' and pwd == 'pwd':
            session['username'] = '******'
            return redirect('/list')
        else:
            erro_msg = 'wrong user or password!'
    else:
        erro_msg = 'need user and pwd'
Exemplo n.º 5
0
 def __init__(self, instance_filename):
     instance = json.loads(fileutil.read_file(instance_filename))
     self.pid = instance["pid"]
     self.address = str(instance["address"])
     self.client = None
Exemplo n.º 6
0
def read_settings(filename):
    return json.loads(fileutil.read_file(filename))