• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python session.SESSION类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ping_callback

 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))
开发者ID:atilacamurca,项目名称:mod-ui,代码行数:6,代码来源:__init__.py


示例17: __init__


#.........这里部分代码省略.........
        self.ui.act_pedalboard_save_as.setEnabled(False)
        self.ui.act_pedalboard_share.setEnabled(False)
        self.ui.menu_Pedalboard.setEnabled(False)

        # disable presets menu
        self.ui.act_presets_new.setEnabled(False)
        self.ui.act_presets_save.setEnabled(False)
        self.ui.act_presets_save_as.setEnabled(False)
        self.ui.menu_Presets.setEnabled(False)

        # initial stopped state
        self.slot_backendFinished(-1, -1)

        # Qt needs this so it properly creates & resizes the webview
        self.ui.stackedwidget.setCurrentIndex(1)
        self.ui.stackedwidget.setCurrentIndex(0)

        # FIXME
        #self.ui.act_backend_stop.setVisible(False)
        #self.ui.act_backend_restart.setVisible(False)

        # ----------------------------------------------------------------------------------------------------
        # Set up GUI (special stuff for Mac OS)

        if MACOS:
            self.ui.act_file_quit.setMenuRole(QAction.QuitRole)
            self.ui.act_settings_configure.setMenuRole(QAction.PreferencesRole)
            self.ui.act_help_about.setMenuRole(QAction.AboutRole)
            #self.ui.menu_Settings.setTitle("Panels")
            #self.ui.menu_Help.hide()

        # ----------------------------------------------------------------------------------------------------
        # Set up GUI (special stuff for Live-MOD ISO)

        if USING_LIVE_ISO:
            self.ui.menubar.hide()
            self.ui.b_start.hide()
            self.ui.b_configure.hide()
            self.ui.b_about.hide()

        # ----------------------------------------------------------------------------------------------------
        # Load Settings

        self.loadSettings(True)

        # ----------------------------------------------------------------------------------------------------
        # Connect actions to functions

        self.SIGUSR1.connect(self.slot_handleSIGUSR1)
        self.SIGTERM.connect(self.slot_handleSIGTERM)

        self.fProccessBackend.error.connect(self.slot_backendError)
        self.fProccessBackend.started.connect(self.slot_backendStarted)
        self.fProccessBackend.finished.connect(self.slot_backendFinished)
        self.fProccessBackend.readyRead.connect(self.slot_backendRead)

        self.fWebServerThread.running.connect(self.slot_webServerRunning)
        self.fWebServerThread.finished.connect(self.slot_webServerFinished)

        self.ui.menu_Pedalboard.aboutToShow.connect(self.slot_pedalboardCheckOnline)

        self.ui.act_file_refresh.triggered.connect(self.slot_fileRefresh)
        self.ui.act_file_inspect.triggered.connect(self.slot_fileInspect)

        self.ui.act_backend_information.triggered.connect(self.slot_backendInformation)
        self.ui.act_backend_start.triggered.connect(self.slot_backendStart)
        self.ui.act_backend_stop.triggered.connect(self.slot_backendStop)
        self.ui.act_backend_restart.triggered.connect(self.slot_backendRestart)

        self.ui.act_pedalboard_new.triggered.connect(self.slot_pedalboardNew)
        self.ui.act_pedalboard_open.triggered.connect(self.slot_pedalboardOpen)
        self.ui.act_pedalboard_save.triggered.connect(self.slot_pedalboardSave)
        self.ui.act_pedalboard_save_as.triggered.connect(self.slot_pedalboardSaveAs)
        self.ui.act_pedalboard_share.triggered.connect(self.slot_pedalboardShare)

        self.ui.act_settings_configure.triggered.connect(self.slot_configure)

        self.ui.act_help_about.triggered.connect(self.slot_about)
        self.ui.act_help_project.triggered.connect(self.slot_showProject)
        self.ui.act_help_website.triggered.connect(self.slot_showWebsite)

        self.ui.b_start.clicked.connect(self.slot_backendStart)
        self.ui.b_configure.clicked.connect(self.slot_configure)
        self.ui.b_about.clicked.connect(self.slot_about)

        # force our custom refresh
        webReloadAction = self.ui.webpage.action(QWebPage.Reload)
        webReloadAction.triggered.disconnect()
        webReloadAction.triggered.connect(self.slot_fileRefresh)

        # ----------------------------------------------------------------------------------------------------
        # Final setup

        self.setProperWindowTitle()
        SESSION.setupApp(self._pedal_changed_callback)

        if not "--no-autostart" in sys.argv:
            QTimer.singleShot(0, self.slot_backendStart)

        QTimer.singleShot(1, self.fixWebViewSize)
开发者ID:moddevices,项目名称:mod-app,代码行数:101,代码来源:mod_host.py


示例18: post

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

        titlesym = symbolify(title)

        # Save over existing bundlepath
        if SESSION.bundlepath and os.path.exists(SESSION.bundlepath) and os.path.isdir(SESSION.bundlepath) and not asNew:
            bundlepath = SESSION.bundlepath

        # Save new
        else:
            lv2path = os.path.expanduser("~/.lv2/") # FIXME: cross-platform
            trypath = os.path.join(lv2path, "%s.pedalboard" % titlesym)

            # if trypath already exists, generate a random bundlepath based on title
            if os.path.exists(trypath):
                from random import randint

                while True:
                    trypath = os.path.join(lv2path, "%s-%i.pedalboard" % (titlesym, randint(1,99999)))
                    if os.path.exists(trypath):
                        continue
                    bundlepath = trypath
                    break

            # trypath doesn't exist yet, use it
            else:
                bundlepath = trypath

                # just in case..
                if not os.path.exists(lv2path):
                    os.mkdir(lv2path)

            os.mkdir(bundlepath)

        # callback for when ingen is done doing its business
        def callback(ok):
            if not ok:
                self.write(json.dumps({ 'ok': False, 'error': "Failed" })) # TODO more descriptive error?
                self.finish()
                return

            # Create a custom manifest.ttl, not created by ingen because we want *.pedalboard extension
            with open(os.path.join(bundlepath, "manifest.ttl"), 'w') as fd:
                fd.write('''\
@prefix ingen: <http://drobilla.net/ns/ingen#> .
@prefix lv2:   <http://lv2plug.in/ns/lv2core#> .
@prefix pedal: <http://portalmod.com/ns/modpedal#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

<%s.ttl>
    lv2:prototype ingen:GraphPrototype ;
    a lv2:Plugin ,
        ingen:Graph ,
        pedal:Pedalboard ;
    rdfs:seeAlso <%s.ttl> .
''' % (titlesym, titlesym))

            # All ok!
            self.set_header('Content-Type', 'application/json')
            self.write(json.dumps({ 'ok': True, 'bundlepath': bundlepath }, default=json_handler))
            self.finish()

        # Ask ingen to save
        SESSION.save_pedalboard(bundlepath, title, callback)
开发者ID:atilacamurca,项目名称:mod-ui,代码行数:66,代码来源:webserver.py


示例19: open

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


示例20: _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), 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
开发者ID:alercunha,项目名称:mod-ui,代码行数:30,代码来源:monitor.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.get_host_platform函数代码示例发布时间:2022-05-27
下一篇:
Python log.info函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap