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


Python history.History类代码示例

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


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

示例1: revert_actions

    def revert_actions(self, arg):
        """
        Calculate the actions necessary to revert to a given state, the
        argument may be one of:
          * complete set of eggs, i.e. a set of egg file names
          * revision number (negative numbers allowed)
          * datetime in ISO format, i.e. YYYY-mm-dd HH:MM:SS
          * simple strings like '1 day ago', see parse_dt module
        """
        if self.hook:
            raise NotImplementedError
        h = History(self.prefixes[0])
        h.update()
        if isinstance(arg, set):
            state = arg
        else:
            state = self._get_state(h, arg)

        curr = h.get_state()
        if state == curr:
            return []

        res = []
        for egg in curr - state:
            res.append(("remove", egg))

        for egg in state - curr:
            if not isfile(join(self.local_dir, egg)):
                self._connect()
                if self.remote.exists(egg):
                    res.append(("fetch_0", egg))
                else:
                    raise EnpkgError("cannot revert -- missing %r" % egg)
            res.append(("install", egg))
        return res
开发者ID:jasonmccampbell,项目名称:enstaller,代码行数:35,代码来源:enpkg.py

示例2: test_partition

    def test_partition(self):
        dynamomessages._show_metadata = True
        all_nodes = self.partition()

        # Display, tweaking ordering of nodes so partition is in the middle
        print History.ladder(force_include=all_nodes, spacing=16, key=lambda x: ' ' if x.name == 'b' else x.name)
        dynamomessages._show_metadata = False
开发者ID:TaoZong,项目名称:Python,代码行数:7,代码来源:test_dynamo.py

示例3: schedule

 def schedule(self, msgs_to_process=None, timers_to_process=None):
     """Schedule given number of pending messages"""
     if msgs_to_process is None:
         msgs_to_process = 32768
     if timers_to_process is None:
         timers_to_process = 32768
     while self.queue:
         msg = self.queue.popleft()
         try:
             c = zerorpc.Client(timeout=1)
             c.connect('tcp://' + msg.to_node)
         except zerorpc.TimeoutExpired:
             _logger.info("Drop %s->%s: %s as destination down", msg.from_node, msg.to_node, msg)
             History.add("drop", msg)
             self.dynamo.retry_request(msg)
         if isinstance(msg, ResponseMessage):
                     # figure out the original request this is a response to
             try:
                 reqmsg = msg.response_to.original_msg
             except Exception:
                 reqmsg = msg.response_to
         History.add("deliver", msg)
         m = pickle.dumps(msg)
         try:
             c.rcvmsg(m)
             c.close()
         except:
             print 'time out'
             print msg.to_node
             self.dynamo.retry_request(msg)
开发者ID:TaoZong,项目名称:Python,代码行数:30,代码来源:framework.py

示例4: Addon

class Addon(AddonCore):
    """"""
    def __init__(self, parent, *args, **kwargs):
        """"""
        AddonCore.__init__(self)
        self.name = _("History")
        self.event_id = events.connect(cons.EVENT_DL_COMPLETE, self.trigger)
        self.parent = parent
        self.config = conf
        self.history = History()
        self.history_tab = HistoryContainer(self.history, self.parent)
    
    def get_menu_item(self):
        pass
        #WIDGET, TITLE, CALLBACK, SENSITIVE = range(4)
        #return (gtk.MenuItem(), _("History"), self.on_history) #can toggle
    
    def get_tab(self):
        return self.history_tab
    
    #def on_history(self, widget):
        #HistoryDlg(self.history, self.parent)
    
    def trigger(self, download_item, *args, **kwargs):
        """"""
        link = download_item.link if download_item.can_copy_link else None
        self.history.set_values(download_item.name, link, download_item.size, download_item.size_complete, download_item.path)
        #remove from the list.
        model = self.parent.downloads_list_gui.treeView.get_model()
        row = self.parent.downloads_list_gui.rows_buffer[download_item.id]
        model.remove(row.iter)
        del self.parent.downloads_list_gui.rows_buffer[download_item.id]
        del api.complete_downloads[download_item.id]
开发者ID:yckart,项目名称:ochDownloader,代码行数:33,代码来源:addon_gui.py

示例5: examine

def examine(lines, pic_kind):
    resolve = [-36, -5, 97, 44, -24]
    length, same, deltaes,days,opens,actuals,expecteds = 0, 0, [],[],[],[],[]
    for line in lines:
        record = History.get_from_historyline(line)
	record = History.norm(record)
	expected = get_expected(resolve, record)
	actual = record.closed_today 
	delta = expected - actual
	deltaes.append(delta)
	days.append(record.day)
	opens.append(record.open_price)
	actuals.append(actual)
	expecteds.append(expected)
	print 'open: %s,actual: %s, expected: %s, delta: %s' % (record.open_price, actual, expected, delta)

	if (expected - record.open_price) * (actual - record.open_price) > 0:
	    same += 1
	length += 1
    print 'direction_same: %d, length: %d, direction_same/length: %s' % (same, length, float(same)/length)
    x = [ i + 1 for i in range(len(opens))]
    if pic_kind == 'delta':
        pydrawer.draw(x, deltaes, 'bo')
    if pic_kind == 'lines':
        pydrawer.draw(x, opens,'k', x, actuals,'r-', x, expecteds,'bo')
开发者ID:wdggat,项目名称:agau,代码行数:25,代码来源:ag_history_price_predict.py

示例6: __init__

class Shell:

  def __init__(self):
    self.builtins = Builtins(self)
    self.completion = Completion(self)
    self.history = History()
    self.javascript = Javascript()
    self.log = Log()
    self.prompt = Prompt()

  def execute(self, command):
    self.log.append(str(self.prompt) + command)
    self.history.append(command)

    if command:
      # execute builtins command
      try:
        self.builtins.execute(command.strip())
      except self.builtins.UnknownCommandError as e:
        self.log.append('websh: command not found: {0}'.format(e.command))
      except Exception as e:
        print 'Error in builtins: {0}'.format(e)

    return json.dumps({'javascript': str(self.javascript),
                       'log': str(self.log),
                       'prompt': str(self.prompt)})

  def template(self):
    # read template file
    file = open('data/template.html', 'r')
    template = string.Template(file.read())
    file.close()

    return template.substitute(log = str(self.log),
                               prompt = str(self.prompt))
开发者ID:Desintegr,项目名称:websh,代码行数:35,代码来源:shell.py

示例7: test_simple_put

 def test_simple_put(self):
     for _ in range(6):
         dynamo1.DynamoNode()
     a = dynamo1.DynamoClientNode('a')
     a.put('K1', None, 1)
     Framework.schedule()
     print History.ladder()
开发者ID:TaoZong,项目名称:Python,代码行数:7,代码来源:test_dynamo.py

示例8: test_put2_fail_nodes23_2

 def test_put2_fail_nodes23_2(self):
     """Show second request for same key skipping failed nodes"""
     (a, pref_list) = self.put_fail_nodes23(dynamo2)
     coordinator = pref_list[0]
     from_line = len(History.history)
     a.put('K1', None, 2, destnode=coordinator)  # Send client request to coordinator for clarity
     Framework.schedule()
     print History.ladder(force_include=pref_list, start_line=from_line, spacing=16)
开发者ID:TaoZong,项目名称:Python,代码行数:8,代码来源:test_dynamo.py

示例9: test_put2_fail_nodes23_5

 def test_put2_fail_nodes23_5(self):
     """Show Put after a failure including handoff, and the resulting Pings"""
     (a, pref_list) = self.put_fail_nodes23(dynamo4)
     coordinator = pref_list[0]
     from_line = len(History.history)
     a.put('K1', None, 2, destnode=coordinator)  # Send client request to coordinator for clarity
     Framework.schedule(timers_to_process=10)
     print History.ladder(force_include=pref_list, start_line=from_line, spacing=16)
开发者ID:TaoZong,项目名称:Python,代码行数:8,代码来源:test_dynamo.py

示例10: cancel_timer

 def cancel_timer(cls, tmsg):
     """Cancel the given timer"""
     for (this_prio, this_tmsg) in cls.pending:
         if this_tmsg == tmsg:
             _logger.debug("Cancel timer %s for node %s reason %s", id(tmsg), tmsg.from_node, tmsg.reason)
             cls.pending.remove((this_prio, this_tmsg))
             History.add("cancel", tmsg)
             return
开发者ID:TaoZong,项目名称:Python,代码行数:8,代码来源:timer.py

示例11: createHistory

def createHistory(portfolioFile = None, forceReload = False):
    # Read all transactions from disk
    transactions = transaction.readTransactions(portfolioFile)
    startDate = transactions[0].date

    # And all investments
    investments = investment.learn_investments(transactions)

    # Build a list of all mentioned tickers
    tickerList = []
    for trans in transactions:
        if trans.ticker not in tickerList:
            tickerList.append(trans.ticker)

    # Hard code currency list.  !! Should pick these out of investments really.
    currencyList = ["USD", "Euro", "NOK"]

    # Build a history of our transactions
    history = History(transactions)

    # Load what we've got from disk
    prices = {}
    Price.loadHistoricalPricesFromDisk(prices)

    # Start reading all the HTML we're going to need now.
    urlCache, currencyInfo, tickerInfo = cacheUrls(tickerList, currencyList, investments, history, startDate, prices, forceReload)

    # Load currency histories
    for currency in currencyInfo:
        Price.getCurrencyHistory(currency[0],
                                 currency[1],
                                 date.today(),
                                 prices,
                                 urlCache)

    # Load current prices from the Web
    Price.loadCurrentPricesFromWeb(history.currentTickers(), prices, urlCache)

    # Now load historical prices from the Web
    for ticker in tickerInfo:
        Price.loadHistoricalPricesFromWeb(ticker[0], ticker[1], ticker[2], prices, urlCache)

    # Fill in any gaps
    Price.fixPriceGaps(prices)

    # Now save any new data to disk
    Price.savePricesToDisk(prices)

    # And fill in any gaps between the last noted price and today
    Price.fixLastPrices(prices, history.currentTickers())

    # Give the prices to our history
    history.notePrices(prices)

    # Done with all the HTML that we read
    #urlCache.clean_urls()

    return (history, investments)
开发者ID:danieltebbutt,项目名称:Portfolio,代码行数:58,代码来源:new.py

示例12: test_get_put_put

 def test_get_put_put(self):
     """Show get-then-put-then-put operation"""
     dynamomessages._show_metadata = True
     (a, pref_list) = self.get_put_get_put()
     coordinator = pref_list[0]
     from_line = len(History.history)
     self.get_put_put(a, coordinator)
     print History.ladder(force_include=pref_list, start_line=from_line, spacing=16)
     dynamomessages._show_metadata = False
开发者ID:TaoZong,项目名称:Python,代码行数:9,代码来源:test_dynamo.py

示例13: HistoryQuery

class HistoryQuery(object):
    def __init__(self, router):
        self._history = History(router)

    def get(self, uid, key):
        return self._history.get(uid, key)

    def put(self, uid, key, **fields):
        self._history.put(uid, key, fields)
开发者ID:virtdev,项目名称:virtdev,代码行数:9,代码来源:query.py

示例14: forward_message

 def forward_message(cls, msg, new_to_node):
     """Forward a message"""
     _logger.info("Enqueue(fwd) %s->%s: %s", msg.to_node, new_to_node, msg)
     fwd_msg = copy.copy(msg)
     fwd_msg.intermediate_node = fwd_msg.to_node
     fwd_msg.original_msg = msg
     fwd_msg.to_node = new_to_node
     cls.queue.append(fwd_msg)
     History.add("forward", fwd_msg)
开发者ID:TaoZong,项目名称:Python,代码行数:9,代码来源:frameworkBack.py

示例15: test_put2_fail_nodes23_3

 def test_put2_fail_nodes23_3(self):
     """Show PingReq failing"""
     (a, pref_list) = self.put_fail_nodes23(dynamo4)
     coordinator = pref_list[0]
     a.put('K1', None, 2, destnode=coordinator)  # Send client request to coordinator for clarity
     Framework.schedule(timers_to_process=0)
     from_line = len(History.history)
     Framework.schedule(timers_to_process=3)
     print History.ladder(force_include=pref_list, start_line=from_line, spacing=16)
开发者ID:TaoZong,项目名称:Python,代码行数:9,代码来源:test_dynamo.py


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