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


Python History.close方法代码示例

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


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

示例1: Timermode

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import close [as 别名]
class Timermode():

    def __init__(self):
        self.timer = None
        self.mode = '3x3'
        self.history = History()

    def nextsolve(self):
        self.scramble = scramble.scramble()
        print("\n" + "Scramble: " + self.scramble + "\n")
        print('0.00', end='\r')
        self.lasttimer = self.timer
        self.timer = Timer()
        time.sleep(0.5)

    def run(self):
        while True:
            self.nextsolve()
            if self.configmode() == -1:
                self.history.close()
                break
            self.playmode()
            self.history.save(self.timer, self.scramble, self.mode)

    def playmode(self):
        self.timer.go(self.mode)
        while True:
            c = getch()
            if c == ' ':
                self.timer.stop()
                return

    def configmode(self):
        while True:
            c = getch()
            if c == ' ':
                break                                      # space = start next solve
            if c == 'q':                                            # q = exit timer mode
                print("Quit Timer\n")
                return -1
            if c == 'p':
                print(self.history.getlast(self.mode, 2))  # p = print last 2 solves
            if c == 'f':
                self.history.deletelast()                  # f = delete last solve
            if c == 'd':                                            # d = set last solve as dnf
                self.history.set_dnf()
                print("DNF nub\n0.00", end="\r")
            if c == '2':                                            # 2 = set last solve as plustwo
                self.history.set_plustwo()
                print("+2 nub\n0.00", end="\r")
            if c == 'm':                                            # m = switch modes(3x3,oh, etc.)
                self.changemode()

    def changemode(self):
        self.mode = input("let's play ")
开发者ID:drumsen,项目名称:pycube,代码行数:57,代码来源:timer.py

示例2: Simulator

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import close [as 别名]

#.........这里部分代码省略.........
				job.status = Job.Status.SUCCEEDED
				# Update queues
				self.jobsQueue.remove(job.jobId)
				self.jobsDone.append(job.jobId)
				# Log
				self.history.logJob(job)
			
			# Check which nodes are available to run tasks
			# =====================================================
			# Maps
			while self.mapQueued()>0 and self.getIdleNodeMap() != None:
				# Get a map that needs to be executed and assign it to a node
				idleNode = self.getIdleNodeMap()
				# TODO policy to decide when to approximate
				#mapAttempt = self.getMapTask(approx=True if self.getNodesUtilization() > 1.8 else False)
				mapAttempt = self.getMapTask()
				mapAttempt.start = self.t
				if mapAttempt.getJob().isMapDropping():
					mapAttempt.drop()
					mapAttempt.finish = self.t
					mapAttempt.approx = False
					completedJobs += mapAttempt.getJob().dropAttempt(mapAttempt)
					# Log
					self.history.logAttempt(mapAttempt)
				else:
					# Start running in a node
					idleNode.assignMap(mapAttempt)
			# Reduces
			while self.redQueued()>0 and self.getIdleNodeRed() != None:
				# Get a map that needs to be executed and assign it to a node
				idleNode = self.getIdleNodeRed()
				redAttempt = self.getRedTask()
				redAttempt.start = self.t
				if redAttempt.getJob().isRedDropping():
					redAttempt.drop()
					redAttempt.finish = self.t
					# Log
					self.history.logAttempt(redAttempt)
				else:
					idleNode.assignRed(redAttempt)
			
			# Node management
			# =====================================================
			# Check if we need less nodes. Idle nodes.
			if self.nodeManagement:
				lessNodes = 0
				lessNodes = min(len(self.getIdleNodesMap()), len(self.getIdleNodesRed()))
				# Check if we need more nodes. Size of the queues.
				moreNodes = 0
				if lessNodes == 0:
					moreNodesMaps = math.ceil(1.0*self.mapQueued() / 3) - self.getWakingNodes()
					moreNodesReds = math.ceil(self.redQueued() / 1) - self.getWakingNodes()
					moreNodes = max(moreNodesMaps, moreNodesReds, 0)
				# Change node status
				for node in self.nodes.values():
					if node.status == 'ON' and not self.isNodeRequired(node.nodeId) and lessNodes > 0:
						lessNodes -= 1
						seconds = node.timeSleep
						if isRealistic():
							seconds = random.gauss(seconds, 0.1*seconds) #+/-10%
						node.status = 'SLEEPING-%d' % seconds
						self.history.logNodeStatus(self.t, node)
					elif node.status == 'SLEEP' and moreNodes > 0:
						moreNodes -= 1
						seconds = node.timeWake
						if isRealistic():
							seconds = random.gauss(seconds, 0.1*seconds) #+/-10%
						node.status = 'WAKING-%d' % seconds
						self.history.logNodeStatus(self.t, node)
					# Transition status
					elif node.status.startswith('SLEEPING-'):
						seconds = int(node.status[len('SLEEPING-'):]) - 1
						if seconds <= 0:
							node.status = 'SLEEP'
							self.history.logNodeStatus(self.t, node)
						else:
							node.status = 'SLEEPING-%d' % seconds
					elif node.status.startswith('WAKING-'):
						seconds = int(node.status[len('WAKING-'):])   - 1
						if seconds <= 0:
							node.status = 'ON'
							self.history.logNodeStatus(self.t, node)
						else:
							node.status = 'WAKING-%d' % seconds
			# Account for power
			power = 0.0
			for node in self.nodes.values():
				power += node.getPower()
			self.history.logPower(self.t, power)
			
			self.energy += 1.0*power # s x W = J
			
			# Progress to next period
			self.t += self.STEP
		
		# Log final output
		if self.logfile != None:
			self.history.close()
			viewer = HistoryViewer(self.history.getFilename())
			viewer.generate()
开发者ID:,项目名称:,代码行数:104,代码来源:

示例3: str

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import close [as 别名]
        log.write('No links found in ' + str(id) + '...')
    else:
      log.write('Comment seen before...skipping...')
  
  log.write('Looping through 10 hottest posts...')
  for submission in submissions:
    id = submission.id
    log.write('Handling post ' + str(id) + '...')
    if id not in all_history:
      log.write('Parsing new post ' + str(id) + '...')
      body = submission.selftext
      links = LinkExtractor.extract_links(body)
      if len(links) > 0:
        for link in links:
          log.write('Storing new link ' + str(link) + '...')
          link_file.add(str(link))
        log.write('Adding ' + str(link) + ' to history...')
        history.add(id)
      else:
        log.write('No links found in ' + str(id) + '...')
    else:
      log.write('Post seen before...skipping...')
else:
  log.write('Failed to get subreddit...')
  log.write('This is most likely due to Reddit\'s request limitations...')
  log.write('Will try again momentarily...')
 
history.close()
log.close()
link_file.close()
开发者ID:abatilo,项目名称:cscq_bot,代码行数:32,代码来源:bot.py


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