Beispiel #1
0
    def setup(self):
        # initialize storage
        # doing it here because it's needed by the server factory
        storage.init(self.config['database'])

        # TODO from configuration
        stor_class = self.config['storage']['class']
        klass = getattr(storage, stor_class)
        self.storage = klass(*self.config['storage']['params'])

        self.keyring = keyring.Keyring(storage.MySQLNetworkStorage(), self.config['fingerprint'], self.network, self.servername, disable_cache=True)
        token_auth = auth.AuthKontalkChecker(self.config['fingerprint'], self.keyring)

        # upload endpoint
        portal = Portal(FileUploadRealm(self), [token_auth])
        resource = HTTPSAuthSessionWrapper(portal, auth.KontalkCertificate)
        self.putChild('upload', resource)

        # download endpoint
        portal = Portal(FileDownloadRealm(self), [token_auth])
        resource = HTTPSAuthSessionWrapper(portal, auth.KontalkCertificate)
        self.putChild('download', resource)

        # http service
        self.factory = server.Site(self)
        sslFactory = MyOpenSSLCertificateOptions(self.config['ssl_key'], self.config['ssl_cert'], self._sslVerify)
        endpoint = SSL4ServerEndpoint(reactor, self.config['bind'][1], sslFactory, interface=str(self.config['bind'][0]))
        svc = StreamServerEndpointService(endpoint, self.factory)
        svc._raiseSynchronously = True
        return svc
Beispiel #2
0
 def test_elasticache(self):
     storage.init(
         "ELASTICACHE",
         "redis://test2.0vgvbw.ng.0001.usw1.cache.amazonaws.com:6379")
     self.assertEqual(storage.elasticache_client.ping(), True)
     msg = b"test msg"
     storage.put("elasticache-test-key", msg)
     self.assertEqual(storage.get("elasticache-test-key"), msg)
Beispiel #3
0
def main():
    storage.init()

    options = docopt(__doc__, version='0.1.0')

    if options['service']:
        do_service(options)
    elif options['repair']:
        do_repair(options)
    elif options['dylib']:
        do_dylib(options)
Beispiel #4
0
    def __init__(self, photo_storage_path, video_storage_path):
        try:
            self.pi_camera_pres = True
            import pi_camera
        except:
            print("WARN : no pi camera library detected !")
            self.pi_camera_pres = False

        try:
            self.gphoto_lib_pres = True
            import gphoto
        except:
            print("WARN : no gphoto library detected !")
            self.gphoto_lib_pres = False

        # Display warning for deprecated Picamera functions (since v1.8)
        warnings.filterwarnings('default', category=DeprecationWarning)

        # Init pygame
        pygame.init()

        # GPIO
        self.gpio = gpio.init(self.gpio_callback_func)

        # Storage init
        self.photo_storage = storage.init(photo_storage_path)
        self.video_storage = storage.init(video_storage_path)

        # Intialize gphoto library
        if self.gphoto_lib_pres:
            self.gp = gphoto.gphoto();

        # Picamera object / objet Picamera
        if self.pi_camera_pres:
            self.pi_camera = pi_camera.camera()

        # Start camera preview / Demarre affichage en direct
        if self.pi_camera_pres:
            self.pi_camera.start()

        # Create interface
        self.ihm = interface.init(pygame, self.pi_camera, "../images/fond.png", "../sounds/snapshot.wav")

        self.capture = capture.init(self.photo_storage, self.video_storage, self.pi_camera)

        # Initialize dubsmash
        self.dubsmash = dubsmash.init(pygame, self.ihm, self.pi_camera, self.capture)

        # Internal flag
        self.led_garland_process_started = False
        self.protect_gpio_double_press   = False
Beispiel #5
0
def init(name, passw):
	global user, password
	user = name
	password = passw
	login()
	storage.init()
	Chat('monchbox') #TODO: possibly use a database to remember rooms to join, settings, etc

	while True:
		event = stack.get()
		try:
			if event.type == 'context': event()
			else: raise Exception('Unrecognized event type ' + event.type)
		except Exception:
			logout()
			raise
			break
		finally: stack.task_done()
Beispiel #6
0
def main(argv=argv, cfg_file=cfg_file, update=1):
    """
    The function is the client entry point.
    """

    start_dir = os.getcwd()
    os.chdir(join(start_dir, dirname(argv[0]), dirname(cfg_file)))
    cfg_file = join(os.getcwd(), os.path.basename(cfg_file))
    loadConfiguration(cfg_file)
    os.chdir(start_dir)
    path.append(config['servers']['path'])
    path.append(config['configobj']['path'])

    # this import must stay here, after the appending of configobj path to path
    import storage
    storage.init(config['storage']['path'])

    # this import must stay here, after the appending of configobj path to path
    from gui import Gui
    try:
        app = QApplication([])
        app.setStyle(QStyleFactory.create("Cleanlooks"))

        gui = Gui(cfg_file)
        if not update:
            gui.displayWarning(PROJECT_NAME, gui._text['UpdateFail'])
        gui.show()
        exit(app.exec_())

    except Exception, e:
        print 'Fatal Exception:', e
        info = getExceptionInfo()
        fd = open(join(config['exceptions']['save_path'], 'exception.txt'), 'a+')
        fd.write(info)
        fd.close()

        if config['exceptions']['send_email']:
            try:
                sendMail("DevClient fatal exception: %s" % e, info)
            except Exception, e:
                print 'Error while sending email:', e
Beispiel #7
0
from tornadio2 import TornadioRouter, SocketServer

logger = logging.getLogger()
console = logging.StreamHandler()
formatter = logging.Formatter("%(asctime)s %(levelname)-8s %(name)s %(lineno)s %(message)s")
console.setFormatter(formatter)
console.setLevel(logging.DEBUG)
logger.addHandler(console)
logger.setLevel(logging.DEBUG)

import runtime.path

runtime.path.bootstrap()
import storage

storage.init()
import ctl
import handler
from runtime import env
from module.store import Store

tornado.locale.load_translations(runtime.path.resources_path("i18n", True))


class SocketIOApplication(tornado.web.Application):
    def __init__(self, **settings):
        params = dict(enabled_protocols=["websocket", "xhr-polling", "jsonp-polling", "htmlfile"])
        router = TornadioRouter(handler.SocketIOHandler, params)
        handlers = router.apply_routes(
            [
                (r"/api/service", handler.ServiceHandler),
Beispiel #8
0
    g_class = "admin"
    clear()
    print("CHUNG LING HIGH SCHOOL")
    print("SCHOOL MANAGEMENT SYSTEM")
    print("< Console Mode >")
    print("\nCurrent User: admin")
    print("\nInput 1 to manually create student data file (with 52 lines).")
    print("Input 2 to modify student data by line.")
    print("Input 3 to change password (including yours).")
    print("Input 0 to log out.")
    i = input("Input: ")
    if i == "0":
        storage.logout()
        msg("Info", "Successfully logged out.")
        loadConsole()
    elif i == "1":
        consoleAdminCreateAccount()
    elif i == "2":
        consoleAdminModifyData()
    elif i == "3":
        consoleAdminChangePassword()
    else:
        msg("Warning", "Please enter a correct input.")
        consoleAdmin()


# SCRIPT

storage.init("data/")
loadConsole()
Beispiel #9
0
def init(config):
    storage.init(config)
Beispiel #10
0
 def test_s3(self):
     storage.init("S3", "storage-module-test")
     msg = bytes(random.randint(1, 10000))
     storage.put("aws-test-key", msg)
     self.assertEqual(storage.get("aws-test-key"), msg)
Beispiel #11
0
    return user


def fetch_author_obj_byname(name):
    uid = storage.usernames[name]
    return fetch_author_obj(uid)


def isValidUser(username):
    if username in storage.usernames.keys():
        return True
    else:
        return False


storage.init()
reload_sessions()

app = Flask(__name__)
app.secret_key = 'fwefwerwertwertert'  #os.urandom(12)


@app.route("/", methods=["GET"])
def _home():
    return render_template('home.html')


@app.route("/signup", methods=["GET", "POST"])
def _signup():
    if request.method == "POST":
        try: