コード例 #1
0
  def on_click_link(self, view, frame, req):
    uri = req.get_uri()

    if uri.startswith("file:///"): return False
    elif uri.startswith("gwibber:"):
      url = urlparse.urlparse(uri)
      cmd = url.path.split("/")[1]
      query = urlparse.parse_qs(url.query)
      query = dict((x,y[0]) for x,y in query.items())
      self.emit("action", uri, cmd, query)
    else: util.load_url(uri)
    return True
コード例 #2
0
ファイル: back.py プロジェクト: mnbi/bloggerglass
 def get(self):
     from_url, back_url = util.load_url(self.request, self.response)
     for pattern in self.EXCLUDED:
         if back_url.find(pattern) > -1:
             back_url = '/'
     logging.info("Back request from %s to %s" % (from_url, back_url))
     self.redirect(back_url)
def run_online_model_experiment():
    data = load_url()
    model_list = [Perceptron(), StochasticGradient(),
                  PassiveAggressive(), ConfidenceWeighted()]
    model_name = ['Perceptron', 'StochasticGradient',
                  'PassiveAggressive', 'ConfidenceWeighted']
    model_name = ['PassiveAggressive']
    model_list = [PassiveAggressive()]
    for idx, model in enumerate(model_list):
        cumu_false_total = 0.0
        cumu_false_negative_total = 0.0
        total_count = 0
        file_false = open('%s_result_f' % model_name[idx], 'w')
        file_false_negative = open('%s_result_fn' % model_name[idx], 'w')
        for i in xrange(len(data)):
            print '%s day(%d)' % (model_name[idx], i)
            x = data[i]['data']
            y = data[i]['labels']
            cumu_false, cumu_false_negative = model.run(x, y)
            cumu_false_total += cumu_false
            cumu_false_negative_total += cumu_false_negative
            total_count += len(y)
            file_false.write("%f\n" % cumu_false_total / total_count)
            file_false_negative.write("%f\n" %
                                      cumu_false_negative_total / total_count)
        file_false.close()
        file_false_negative.close()
コード例 #4
0
ファイル: gdoc.py プロジェクト: molobrakos/dbdbscrape
def download():
    url = read_file(FILE_GDOC).strip()
    print("loading %s" % url)
    sheet = load_url(url)
    phenos = read_csv(StringIO(sheet))
    sel = phenos[phenos["malformation?"] == "y"]["phenotype"]
    sel.to_csv(FILE_SELECTION, index=False)
    print("got %d selected phenotypes out of %d, stored in %s" %
          len(sel), len(phenos), FILE_SELECTION)
def run_speed_test():
    data = load_url()
    x = data[0]['data'][:1000]
    y = data[0]['labels'][:1000]
    model_list = [Perceptron(), StochasticGradient(),
                  PassiveAggressive(), ConfidenceWeighted()]
    model_name = ['Perceptron', 'StochasticGradient',
                  'PassiveAggressive', 'ConfidenceWeighted']
    for idx, model in enumerate(model_list):
        start = time()
        model.run(x[:1000], y[:1000])
        print "%s run %f sec" % (model_name[idx], time() - start)
def run_pca_speed_test():
    data = load_url()
    (U, S, V) = svds(data[0]['data'].T, 100)
    U = csc_matrix(U)
    x = data[0]['data'][:1000]
    y = data[0]['labels'][:1000]
    model_list = [Perceptron(), StochasticGradient(),
                  PassiveAggressive(), ConfidenceWeighted()]
    model_name = ['Perceptron', 'StochasticGradient',
                  'PassiveAggressive', 'ConfidenceWeighted']
    pca_x = x.dot(U)
    for idx, model in enumerate(model_list):
        start = time()
        model.run(x, y)
        print "%s run %f sec (no_pca)" % (model_name[idx], time() - start)
        start = time()
        for i in range(1, x.shape[0]):
            new_xi = x[i, :].dot(U)
        model.reset()
        model.run(pca_x, y)
        print "%s run %f sec (with_pca)" % (model_name[idx], time() - start)
コード例 #7
0
ファイル: client.py プロジェクト: SMIDEC/gwibber-lc
    def setup_menu(self):
        ui_string = """
    <ui>
      <menubar name="menubar_main">
        <menu action="menu_gwibber">
          <menuitem action="refresh" />
          <menuitem action="search" />
          <separator/>
          <menuitem action="new_stream" />
          <menuitem action="close_window" />
          <menuitem action="close_stream" />
          <separator/>
          <menuitem action="quit" />
        </menu>

        <menu action="menu_edit">
          <menuitem action="accounts" />
          <menuitem action="preferences" />
        </menu>

        <menu action="menu_help">
          <menuitem action="help_online" />
          <menuitem action="help_translate" />
          <menuitem action="help_report" />
          <separator/>
          <menuitem action="about" />
        </menu>
      </menubar>

      <popup name="menu_tray">
        <menuitem action="refresh" />
        <separator />
        <menuitem action="accounts" />
        <menuitem action="preferences" />
        <separator />
        <menuitem action="quit" />
      </popup>
    </ui>
    """

        self.actions = gtk.ActionGroup("Actions")
        self.actions.add_actions([
            ("menu_gwibber", None, _("_Gwibber")),
            ("menu_edit", None, _("_Edit")),
            ("menu_help", None, _("_Help")),
            ("refresh", gtk.STOCK_REFRESH, _("_Refresh"), "F5", None,
             self.on_refresh),
            ("search", gtk.STOCK_FIND, _("_Search"), "<ctrl>F", None,
             self.on_search),
            ("accounts", None, _("_Accounts"), "<ctrl><shift>A", None,
             self.on_accounts),
            ("preferences", gtk.STOCK_PREFERENCES, _("_Preferences"),
             "<ctrl>P", None, self.on_preferences),
            ("about", gtk.STOCK_ABOUT, _("_About"), None, None, self.on_about),
            ("quit", gtk.STOCK_QUIT, _("_Quit"), "<ctrl>Q", None,
             self.on_quit),
            ("new_stream", gtk.STOCK_NEW, _("_New Stream"), "<ctrl>n", None,
             self.on_new_stream),
            ("close_window", gtk.STOCK_CLOSE, _("_Close Window"),
             "<ctrl><shift>W", None, self.on_window_close),
            ("close_stream", gtk.STOCK_CLOSE, _("_Close Stream"), "<ctrl>W",
             None, self.on_close_stream),
            ("help_online", None, _("Get Help Online..."), None, None,
             lambda *a: util.load_url(QUESTIONS_URL)),
            ("help_translate", None, _("Translate This Application..."), None,
             None, lambda *a: util.load_url(TRANSLATE_URL)),
            ("help_report", None, _("Report A Problem..."), None, None,
             lambda *a: util.load_url(BUG_URL)),
        ])

        ui = gtk.UIManager()
        ui.insert_action_group(self.actions, pos=0)
        ui.add_ui_from_string(ui_string)

        # Add the old CTRL+R shortcut for legacy users
        refresh = ui.get_widget('/menubar_main/menu_gwibber/refresh')
        key, mod = gtk.accelerator_parse("<ctrl>R")
        refresh.add_accelerator("activate", ui.get_accel_group(), key, mod,
                                gtk.ACCEL_VISIBLE)

        if appindicator:
            # Use appindicators to get quicklists in unity
            self.ind = appindicator.Indicator(
                "Gwibber", "applications-microblogging-panel",
                appindicator.CATEGORY_APPLICATION_STATUS)

            # create a menu
            self.ai_menu = gtk.Menu()

            self.ai_menu.append(gtk.SeparatorMenuItem())
            ai_refresh = gtk.MenuItem(_("_Refresh"))
            ai_refresh.connect("activate", self.on_refresh)
            self.ai_menu.append(ai_refresh)

            ai_accounts = gtk.MenuItem(_("_Accounts"))
            ai_accounts.connect("activate", self.on_accounts)
            self.ai_menu.append(ai_accounts)

            ai_preferences = gtk.MenuItem(_("_Preferences"))
            ai_preferences.connect("activate", self.on_preferences)
            self.ai_menu.append(ai_preferences)

            # show the items
            self.ai_menu.show_all()

            self.ind.set_menu(self.ai_menu)

            # End use appindicators to get quicklists in unity

        return ui
コード例 #8
0
ファイル: client.py プロジェクト: Alberto-Beralix/Beralix
  def setup_menu(self):
    ui_string = """
    <ui>
      <menubar name="menubar_main">
        <menu action="menu_gwibber">
          <menuitem action="refresh" />
          <menuitem action="search" />
          <separator/>
          <menuitem action="new_stream" />
          <menuitem action="close_window" />
          <menuitem action="close_stream" />
          <separator/>
          <menuitem action="quit" />
        </menu>

        <menu action="menu_edit">
          <menuitem action="accounts" />
          <menuitem action="preferences" />
        </menu>

        <menu action="menu_help">
          <menuitem action="help_online" />
          <menuitem action="help_translate" />
          <menuitem action="help_report" />
          <separator/>
          <menuitem action="about" />
        </menu>
      </menubar>

      <popup name="menu_tray">
        <menuitem action="refresh" />
        <separator />
        <menuitem action="accounts" />
        <menuitem action="preferences" />
        <separator />
        <menuitem action="quit" />
      </popup>
    </ui>
    """

    self.actions = gtk.ActionGroup("Actions")
    self.actions.add_actions([
      ("menu_gwibber", None, _("_Gwibber")),
      ("menu_edit", None, _("_Edit")),
      ("menu_help", None, _("_Help")),

      ("refresh", gtk.STOCK_REFRESH, _("_Refresh"), "F5", None, self.on_refresh),
      ("search", gtk.STOCK_FIND, _("_Search"), "<ctrl>F", None, self.on_search),
      ("accounts", None, _("_Accounts"), "<ctrl><shift>A", None, self.on_accounts),
      ("preferences", gtk.STOCK_PREFERENCES, _("_Preferences"), "<ctrl>P", None, self.on_preferences),
      ("about", gtk.STOCK_ABOUT, _("_About"), None, None, self.on_about),
      ("quit", gtk.STOCK_QUIT, _("_Quit"), "<ctrl>Q", None, self.on_quit),

      ("new_stream", gtk.STOCK_NEW, _("_New Stream"), "<ctrl>n", None, self.on_new_stream),
      ("close_window", gtk.STOCK_CLOSE, _("_Close Window"), "<ctrl><shift>W", None, self.on_window_close),
      ("close_stream", gtk.STOCK_CLOSE, _("_Close Stream"), "<ctrl>W", None, self.on_close_stream),

      ("help_online", None, _("Get Help Online..."), None, None, lambda *a: util.load_url(QUESTIONS_URL)),
      ("help_translate", None, _("Translate This Application..."), None, None, lambda *a: util.load_url(TRANSLATE_URL)),
      ("help_report", None, _("Report A Problem..."), None, None, lambda *a: util.load_url(BUG_URL)),
    ])

    ui = gtk.UIManager()
    ui.insert_action_group(self.actions, pos=0)
    ui.add_ui_from_string(ui_string)
    
    # Add the old CTRL+R shortcut for legacy users
    refresh = ui.get_widget('/menubar_main/menu_gwibber/refresh')
    key, mod = gtk.accelerator_parse("<ctrl>R")
    refresh.add_accelerator("activate", ui.get_accel_group(), key, mod, gtk.ACCEL_VISIBLE)

    if appindicator:
      # Use appindicators to get quicklists in unity
      self.ind = appindicator.Indicator ("Gwibber",
                                    "applications-microblogging-panel",
                                    appindicator.CATEGORY_APPLICATION_STATUS)

      # create a menu
      self.ai_menu = gtk.Menu()

      self.ai_menu.append(gtk.SeparatorMenuItem())
      ai_refresh = gtk.MenuItem(_("_Refresh"))
      ai_refresh.connect("activate", self.on_refresh)
      self.ai_menu.append(ai_refresh)

      ai_accounts = gtk.MenuItem(_("_Accounts"))
      ai_accounts.connect("activate", self.on_accounts)
      self.ai_menu.append(ai_accounts)

      ai_preferences = gtk.MenuItem(_("_Preferences"))
      ai_preferences.connect("activate", self.on_preferences)
      self.ai_menu.append(ai_preferences)

      # show the items
      self.ai_menu.show_all()

      self.ind.set_menu(self.ai_menu)

      # End use appindicators to get quicklists in unity

    return ui
def run_all_svm_experiment():
    data = load_url()
    svm_once(data)
    svm_daily(data)
    svm_cum(data)
コード例 #10
0
    def setup_menu(self):
        ui_string = """
    <ui>
      <menubar name="menubar_main">
        <menu action="menu_gwibber">
          <menuitem action="refresh" />
          <menuitem action="search" />
          <separator/>
          <menuitem action="new_stream" />
          <menuitem action="close_window" />
          <menuitem action="close_stream" />
          <separator/>
          <menuitem action="quit" />
        </menu>

        <menu action="menu_edit">
          <menuitem action="accounts" />
          <menuitem action="preferences" />
        </menu>

        <menu action="menu_help">
          <menuitem action="help_online" />
          <menuitem action="help_translate" />
          <menuitem action="help_report" />
          <separator/>
          <menuitem action="about" />
        </menu>
      </menubar>

      <popup name="menu_tray">
        <menuitem action="refresh" />
        <separator />
        <menuitem action="accounts" />
        <menuitem action="preferences" />
        <separator />
        <menuitem action="quit" />
      </popup>
    </ui>
    """

        self.actions = gtk.ActionGroup("Actions")
        self.actions.add_actions([
            ("menu_gwibber", None, _("_Gwibber")),
            ("menu_edit", None, _("_Edit")),
            ("menu_help", None, _("_Help")),
            ("refresh", gtk.STOCK_REFRESH, _("_Refresh"), "F5", None,
             self.on_refresh),
            ("search", gtk.STOCK_FIND, _("_Search"), "<ctrl>F", None,
             self.on_search),
            ("accounts", None, _("_Accounts"), "<ctrl><shift>A", None,
             self.on_accounts),
            ("preferences", gtk.STOCK_PREFERENCES, _("_Preferences"),
             "<ctrl>P", None, self.on_preferences),
            ("about", gtk.STOCK_ABOUT, _("_About"), None, None, self.on_about),
            ("quit", gtk.STOCK_QUIT, _("_Quit"), "<ctrl>Q", None,
             self.on_quit),
            ("new_stream", gtk.STOCK_NEW, _("_New Stream"), "<ctrl>n", None,
             self.on_new_stream),
            ("close_window", gtk.STOCK_CLOSE, _("_Close Window"),
             "<ctrl><shift>W", None, self.on_window_close),
            ("close_stream", gtk.STOCK_CLOSE, _("_Close Stream"), "<ctrl>W",
             None, self.on_close_stream),
            ("help_online", None, _("Get Help Online..."), None, None,
             lambda *a: util.load_url(QUESTIONS_URL)),
            ("help_translate", None, _("Translate This Application..."), None,
             None, lambda *a: util.load_url(TRANSLATE_URL)),
            ("help_report", None, _("Report A Problem..."), None, None,
             lambda *a: util.load_url(BUG_URL)),
        ])

        ui = gtk.UIManager()
        ui.insert_action_group(self.actions, pos=0)
        ui.add_ui_from_string(ui_string)

        # Add the old CTRL+R shortcut for legacy users
        refresh = ui.get_widget('/menubar_main/menu_gwibber/refresh')
        key, mod = gtk.accelerator_parse("<ctrl>R")
        refresh.add_accelerator("activate", ui.get_accel_group(), key, mod,
                                gtk.ACCEL_VISIBLE)

        return ui
コード例 #11
0
 def action(self, w, client, msg):
     if msg.has_key("url"):
         util.load_url(msg["url"])
     elif msg.has_key("images"):
         util.load_url(msg["images"][0]["url"])
コード例 #12
0
ファイル: actions.py プロジェクト: Alberto-Beralix/Beralix
 def action(self, w, client, msg):
   if msg.has_key("url"):
     util.load_url(msg["url"])
   elif msg.has_key("images"):
     util.load_url(msg["images"][0]["url"])
コード例 #13
0
ファイル: client.py プロジェクト: SMIDEC/gwibber-lc
  def setup_menu(self):
    ui_string = """
    <ui>
      <menubar name="menubar_main">
        <menu action="menu_gwibber">
          <menuitem action="refresh" />
          <menuitem action="search" />
          <separator/>
          <menuitem action="new_stream" />
          <menuitem action="close_window" />
          <menuitem action="close_stream" />
          <separator/>
          <menuitem action="quit" />
        </menu>

        <menu action="menu_edit">
          <menuitem action="accounts" />
          <menuitem action="preferences" />
        </menu>

        <menu action="menu_help">
          <menuitem action="help_online" />
          <menuitem action="help_translate" />
          <menuitem action="help_report" />
          <separator/>
          <menuitem action="about" />
        </menu>
      </menubar>

      <popup name="menu_tray">
        <menuitem action="refresh" />
        <separator />
        <menuitem action="accounts" />
        <menuitem action="preferences" />
        <separator />
        <menuitem action="quit" />
      </popup>
    </ui>
    """

    self.actions = gtk.ActionGroup("Actions")
    self.actions.add_actions([
      ("menu_gwibber", None, _("_Gwibber")),
      ("menu_edit", None, _("_Edit")),
      ("menu_help", None, _("_Help")),

      ("refresh", gtk.STOCK_REFRESH, _("_Refresh"), "F5", None, self.on_refresh),
      ("search", gtk.STOCK_FIND, _("_Search"), "<ctrl>F", None, self.on_search),
      ("accounts", None, _("_Accounts"), "<ctrl><shift>A", None, self.on_accounts),
      ("preferences", gtk.STOCK_PREFERENCES, _("_Preferences"), "<ctrl>P", None, self.on_preferences),
      ("about", gtk.STOCK_ABOUT, _("_About"), None, None, self.on_about),
      ("quit", gtk.STOCK_QUIT, _("_Quit"), "<ctrl>Q", None, self.on_quit),

      ("new_stream", gtk.STOCK_NEW, _("_New Stream"), "<ctrl>n", None, self.on_new_stream),
      ("close_window", gtk.STOCK_CLOSE, _("_Close Window"), "<ctrl><shift>W", None, self.on_window_close),
      ("close_stream", gtk.STOCK_CLOSE, _("_Close Stream"), "<ctrl>W", None, self.on_close_stream),

      ("help_online", None, _("Get Help Online..."), None, None, lambda *a: util.load_url(QUESTIONS_URL)),
      ("help_translate", None, _("Translate This Application..."), None, None, lambda *a: util.load_url(TRANSLATE_URL)),
      ("help_report", None, _("Report A Problem..."), None, None, lambda *a: util.load_url(BUG_URL)),
    ])

    ui = gtk.UIManager()
    ui.insert_action_group(self.actions, pos=0)
    ui.add_ui_from_string(ui_string)
    
    # Add the old CTRL+R shortcut for legacy users
    refresh = ui.get_widget('/menubar_main/menu_gwibber/refresh')
    key, mod = gtk.accelerator_parse("<ctrl>R")
    refresh.add_accelerator("activate", ui.get_accel_group(), key, mod, gtk.ACCEL_VISIBLE)

    return ui