当前位置: 首页>>代码示例>>Python>>正文


Python session.SESSION类代码示例

本文整理汇总了Python中mod.session.SESSION的典型用法代码示例。如果您正苦于以下问题:Python SESSION类的具体用法?Python SESSION怎么用?Python SESSION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SESSION类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_file

    def process_file(self, data, callback=lambda:None):
        filename = os.path.join(self.destination_dir, data['filename'])

        if not os.path.exists(filename):
            callback()
            return

        if not os.path.exists(self.destination_dir):
            os.mkdir(self.destination_dir)

        # FIXME - don't use external tools!
        from subprocess import getoutput
        tar_output = getoutput('env LANG=C tar -xvf "%s" -C "%s"' % (filename, self.destination_dir))
        bundlepath = os.path.join(self.destination_dir, tar_output.strip().split("\n", 1)[0])

        if not os.path.exists(bundlepath):
            raise IOError(bundlepath)

        # make sure pedalboard is valid
        name = get_pedalboard_name(bundlepath)

        SESSION.load_pedalboard(bundlepath, name)

        os.remove(filename)
        callback()
开发者ID:EQ4,项目名称:mod-ui,代码行数:25,代码来源:webserver.py

示例2: get

 def get(self, instance):
     instance = instance
     x = int(float(self.get_argument('x')))
     y = int(float(self.get_argument('y')))
     SESSION.effect_position(instance, x, y)
     self.set_header('Content-Type', 'application/json')
     self.write(json.dumps(True))
开发者ID:alercunha,项目名称:mod-ui,代码行数:7,代码来源:webserver.py

示例3: check_environment

def check_environment(callback):
    from mod.settings import (HARDWARE_DIR,
                              DEVICE_SERIAL, DEVICE_MODEL,
                              DOWNLOAD_TMP_DIR, BANKS_JSON_FILE, HTML_DIR)
    from mod import indexing
    from mod.session import SESSION

    for dirname in (HARDWARE_DIR, DOWNLOAD_TMP_DIR):
        if not os.path.exists(dirname):
            os.makedirs(dirname)

    if not os.path.exists(BANKS_JSON_FILE):
        fh = open(BANKS_JSON_FILE, 'w')
        fh.write("[]")
        fh.close()

    # TEMPORARIO, APENAS NO DESENVOLVIMENTO
    if os.path.exists(DEVICE_SERIAL) and not os.path.exists(DEVICE_MODEL):
        serial = open(DEVICE_SERIAL).read()
        model = re.search('^[A-Z]+').group()
        open(DEVICE_MODEL, 'w').write(model)

    def ping_callback(ok):
        if ok:
            pass
        else:
            # calls ping again every one second
            ioloop.IOLoop.instance().add_timeout(timedelta(seconds=1), lambda:SESSION.ping(ping_callback))
    SESSION.ping(ping_callback)
开发者ID:ViktorNova,项目名称:mod-ui,代码行数:29,代码来源:__init__.py

示例4: slot_backendStartPhase2

    def slot_backendStartPhase2(self):
        if self.fProccessBackend.state() == QProcess.NotRunning:
            return

        if not self.fNeedsSessionReconnect:
            # we'll need it for next time
            self.fNeedsSessionReconnect = True
        else:
            # we need it now
            SESSION.reconnectApp()

        self.fWebServerThread.start()
开发者ID:moddevices,项目名称:mod-app,代码行数:12,代码来源:mod_host.py

示例5: check_environment

def check_environment(callback):
    from mod.settings import (EFFECT_DIR, HARDWARE_DIR, INDEX_PATH,
                              DEVICE_SERIAL, DEVICE_MODEL,
                              DOWNLOAD_TMP_DIR, BANKS_JSON_FILE, HTML_DIR)
    from mod import indexing
    from mod.session import SESSION

    for dirname in (EFFECT_DIR, HARDWARE_DIR, DOWNLOAD_TMP_DIR):
        if not os.path.exists(dirname):
            os.makedirs(dirname)

    if not os.path.exists(BANKS_JSON_FILE):
        fh = open(BANKS_JSON_FILE, 'w')
        fh.write("[]")
        fh.close()

    # Index creation will check consistency and rebuild index if necessary
    effect_index = indexing.EffectIndex()

    # Migrations. Since we don't have a migration mechanism, let's do it here
    # TODO Migration system where we'll have migration scripts that will be marked as
    # already executed
    for effect_id in os.listdir(EFFECT_DIR):
        if effect_id.endswith('.metadata'):
            continue
        path = os.path.join(EFFECT_DIR, '%s.metadata' % effect_id)
        metadata = {}
        try:
            if os.path.exists(path):
                metadata = json.loads(open(path).read())
        except:
            pass
        metadata['release'] = metadata.get('release', 1)
        open(path, 'w').write(json.dumps(metadata))
    # TODO check if all pedalboards in banks database really exist, otherwise remove them from banks
    ensure_index_sync(effect_index, EFFECT_DIR)

    # TEMPORARIO, APENAS NO DESENVOLVIMENTO
    if os.path.exists(DEVICE_SERIAL) and not os.path.exists(DEVICE_MODEL):
        serial = open(DEVICE_SERIAL).read()
        model = re.search('^[A-Z]+').group()
        open(DEVICE_MODEL, 'w').write(model)

    def ping_callback(ok):
        if ok:
            pass
        else:
            # calls ping again every one second
            ioloop.IOLoop.instance().add_timeout(timedelta(seconds=1), lambda:SESSION.ping(ping_callback))
    SESSION.ping(ping_callback)
开发者ID:atilacamurca,项目名称:mod-ui,代码行数:50,代码来源:__init__.py

示例6: index

    def index(self):
        context = {}

        with open(DEFAULT_ICON_TEMPLATE, 'r') as fd:
            default_icon_template = tornado.escape.squeeze(fd.read().replace("'", "\\'"))

        with open(DEFAULT_SETTINGS_TEMPLATE, 'r') as fd:
            default_settings_template = tornado.escape.squeeze(fd.read().replace("'", "\\'"))

        context = {
            'default_icon_template': default_icon_template,
            'default_settings_template': default_settings_template,
            'cloud_url': CLOUD_HTTP_ADDRESS,
            'hardware_profile': b64encode(json.dumps(SESSION.get_hardware()).encode("utf-8")),
            'max_screenshot_width': MAX_SCREENSHOT_WIDTH,
            'max_screenshot_height': MAX_SCREENSHOT_HEIGHT,
            'package_server_address': PACKAGE_SERVER_ADDRESS or '',
            'default_package_server_port': DEFAULT_PACKAGE_SERVER_PORT,
            'package_repository': PACKAGE_REPOSITORY,
            'js_custom_channel': 'true' if JS_CUSTOM_CHANNEL else 'false',
            'auto_cloud_backup': 'true' if AUTO_CLOUD_BACKUP else 'false',
            'avatar_url': AVATAR_URL,
            'version': self.get_argument('v'),
            'bundlepath': json.dumps(SESSION.bundlepath),
            'title': json.dumps(SESSION.title),
            'fulltitle': SESSION.title or "Untitled",
            'using_app': json.dumps(APP),
            'using_desktop': json.dumps(DESKTOP),
        }
        return context
开发者ID:EQ4,项目名称:mod-ui,代码行数:30,代码来源:webserver.py

示例7: get

 def get(self):
     devsInUse, devList = SESSION.web_get_midi_device_list()
     self.write(json.dumps({
         "devsInUse": devsInUse,
         "devList"  : devList
     }))
     self.finish()
开发者ID:EQ4,项目名称:mod-ui,代码行数:7,代码来源:webserver.py

示例8: post

    def post(self):
        bundlepath = self.get_argument("bundlepath")

        try:
            name = get_pedalboard_name(bundlepath)
        except Exception as e:
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps({ 'ok': False, 'error': str(e).split(") - ",1)[-1] }))
            self.finish()
            return

        SESSION.load_pedalboard(bundlepath, name)

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps({
            'ok':   True,
            'name': name
        }))
        self.finish()
开发者ID:EQ4,项目名称:mod-ui,代码行数:19,代码来源:webserver.py

示例9: post

    def post(self):
        title = self.get_argument('title')
        as_new = bool(int(self.get_argument('asNew')))

        try:
            uid = SESSION.save_pedalboard(title, as_new)
        except Pedalboard.ValidationError as e:
            self.write(json.dumps({ 'ok': False, 'error': str(e) }))
            self.finish()
            raise StopIteration

        THUMB_GENERATOR.schedule_thumbnail(uid)

        self.set_header('Content-Type', 'application/json')
        self.write(json.dumps({ 'ok': True, 'uid': uid }, default=json_handler))
        self.finish()
开发者ID:alercunha,项目名称:mod-ui,代码行数:16,代码来源:webserver.py

示例10: get

 def get(self):
     SESSION.reset(self.result)
开发者ID:atilacamurca,项目名称:mod-ui,代码行数:2,代码来源:webserver.py

示例11: on_close

 def on_close(self):
     print("atom websocket close")
     SESSION.websocket_closed(self)
开发者ID:EQ4,项目名称:mod-ui,代码行数:3,代码来源:webserver.py

示例12: open

 def open(self):
     print("atom websocket open")
     SESSION.websocket_opened(self)
开发者ID:EQ4,项目名称:mod-ui,代码行数:3,代码来源:webserver.py

示例13: stop

def stop():
    tornado.ioloop.IOLoop.instance().stop()
    SESSION.stop_timers()
开发者ID:EQ4,项目名称:mod-ui,代码行数:3,代码来源:webserver.py

示例14: start

def start():
    SESSION.start_timers()
    tornado.ioloop.IOLoop.instance().start()
开发者ID:EQ4,项目名称:mod-ui,代码行数:3,代码来源:webserver.py

示例15: _process_msg

    def _process_msg(self, msg):
        from mod.session import SESSION

        try:
            cmd, instance, port, value =  msg.replace("\x00", "").split()
            assert cmd == "monitor"
            instance = int(instance)
            value = float(value)
        except (ValueError, AssertionError) as e:
            # TODO: tratar error
            pass
        else:
            if instance == CLIPMETER_IN:
                if port == CLIPMETER_MON_L:
                    SESSION.clipmeter(0, value)
                elif port == CLIPMETER_MON_R:
                    SESSION.clipmeter(1, value)

            elif instance == CLIPMETER_OUT:
                if port == CLIPMETER_MON_L:
                    SESSION.clipmeter(2, value)
                elif port == CLIPMETER_MON_R:
                    SESSION.clipmeter(3, value)

            elif instance == PEAKMETER_IN:
                if port == PEAKMETER_MON_VALUE_L:
                    self.pkm_inl_value = value
                    SESSION.peakmeter(0, self.pkm_inl_value, self.pkm_inl_peak)
                elif port == PEAKMETER_MON_VALUE_R:
                    self.pkm_inr_value = value
                    SESSION.peakmeter(1, self.pkm_inr_value, self.pkm_inr_peak)

                if port == PEAKMETER_MON_PEAK_L:
                    self.pkm_inl_peak = value
                    SESSION.peakmeter(0, self.pkm_inl_value, self.pkm_inl_peak)
                elif port == PEAKMETER_MON_PEAK_R:
                    self.pkm_inr_peak = value
                    SESSION.peakmeter(1, self.pkm_inr_value, self.pkm_inr_peak)

            elif instance == PEAKMETER_OUT:
                if port == PEAKMETER_MON_VALUE_L:
                    self.pkm_outl_value = value
                    SESSION.peakmeter(2, self.pkm_outl_value, self.pkm_outl_peak)
                elif port == PEAKMETER_MON_VALUE_R:
                    self.pkm_outr_value = value
                    SESSION.peakmeter(3, self.pkm_outr_value, self.pkm_outr_peak)

                if port == PEAKMETER_MON_PEAK_L:
                    self.pkm_outl_peak = value
                    SESSION.peakmeter(2, self.pkm_outl_value, self.pkm_outl_peak)
                elif port == PEAKMETER_MON_PEAK_R:
                    self.pkm_outr_peak = value
                    SESSION.peakmeter(3, self.pkm_outr_value, self.pkm_outr_peak)

            elif instance == TUNER:
                SESSION.tuner(value)
        self._handle_conn()
开发者ID:ViktorNova,项目名称:mod-ui,代码行数:57,代码来源:monitor.py


注:本文中的mod.session.SESSION类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。