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


Python Time类代码示例

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


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

示例1: run

  def run(self):
    #--ref to: http://www.codeproject.com/Articles/36459/PID-process-control-a-Cruise-Control-example

    lastTs=Time.currentTime();
    previousError=0;
    integral=0;
    Kp=1.2;
    Ki=0.003;
    Kd=1;
    pV=0.0;
    noise=0.0;
    while(not self.done_):
      self.lock_.acquire();

      tS=Time.currentTime();
      dT=tS-lastTs;
      error=self.pRef_-self.pResponse_;
      integral=integral+error*dT;
      derivative=(error-previousError)/dT;
      output=Kp*error+Ki*integral+Kd*derivative;
      previousError=error;
      pV=pV+(output*0.20)-(pV*0.10)+noise;
      dP=pV*dT;
      self.pResponse_ = self.pResponse_+dP;
      lastTs=tS;

#     self.pResponse_ = self.pResponse_ + dP;
      self.D_.append((Time.currentTime(),self.pResponse_));

      self.lock_.release();
      time.sleep(ControlLoopCycle);
开发者ID:fsk-software,项目名称:pub,代码行数:31,代码来源:Device.py

示例2: startDose

    def startDose(doseLength, waitTime):
        if(shouldDose == True):
            doseLock = True
            t0 = Utility.currentTimeMillis()
            
            #set dig output pin to start dosing 
            try:
                ik.interfaceKit.setOutputState(0, 1)
            except PhidgetException as e:
                doseLock = False 
                ik.interfaceKit.setOutputState(0, 0)
                print("Phidget Exception %i: %s" % (e.code, e.details))
                print("Exiting....")
                exit(1)

            print("setting dig output to 1")

            # dose until the dose time is met or something else releases the lock 
            while((Utility.currentTimeMillis() - t0) < timeToDose * 1000 or doseLock != True):    
                Time.sleep(0.1)
             
            try:
                ik.interfaceKit.setOutputState(0, 0)
                doseLock = False
                print("dosed for %i second out put changed to 0" % (timeToDose))
            except PhidgetException as e:
                doseLock = False
                print("Phidget Exception %i: %s" % (e.code, e.details))
                print("Exiting....")
                exit(1)
            doseLock = False
开发者ID:pbehrens,项目名称:ph-doser,代码行数:31,代码来源:dosecontroller.py

示例3: misc_setup

def misc_setup(rps):
	"""Set default change ownership flag, umask, relay regexps"""
	os.umask(077)
	Time.setcurtime(Globals.current_time)
	SetConnections.UpdateGlobal("client_conn", Globals.local_connection)
	Globals.postset_regexp('no_compression_regexp',
						   Globals.no_compression_regexp_string)
	for conn in Globals.connections:
		conn.robust.install_signal_handlers()
		conn.Hardlink.initialize_dictionaries()
开发者ID:blackcoffeerider,项目名称:rdiff-backup,代码行数:10,代码来源:Main.py

示例4: validate

 def validate(self):
     if self.number == 0 or self.begin == '' or self.end == '' or self.text is None: return False
     zbegin = re.split('\W+', self.begin)
     zend = re.split('\W+', self.end)
     self.time_begin = Time(int(zbegin[0]), int(zbegin[1]), int(zbegin[2]), int(zbegin[3]))
     self.time_end = Time(int(zend[0]), int(zend[1]), int(zend[2]), int(zend[3]))
     self.set_mt()
     del self.begin
     del self.end
     return True
开发者ID:Nelgamix,项目名称:python_subtitles_utilities,代码行数:10,代码来源:Subtitle.py

示例5: manageTime

	def manageTime(self):
		t=Time()
		if self.clock==None:
			self.clock=ClockThread(t.getCurrentTime(),self.pool.getTime())#obtiene el tiempo actual
			self.connect(self.clock,SIGNAL("timeOver()"),self.timeEnding)
		else:
			self.clock.setStartTime(t.getCurrentTime())

		#manda a ejecutar un hilo que consultara el tiempo
		self.clock.start()
开发者ID:lhtc9,项目名称:RSS-Reader,代码行数:10,代码来源:RssGUI.py

示例6: manageTime

	def manageTime(self):
		t=Time()#este objeto permite extraer el tiempo actual del sistema
		if self.clock==None:
			#se envia al hilo el tiempo actual y el maximo tiempo de espera
			self.clock=ClockThread(t.getCurrentTime(),self.pool.getTime())#obtiene el tiempo actual
			self.connect(self.clock,SIGNAL("timeOver()"),self.timeEnding)
		else:
			self.clock.setMaxTime(self.pool.getTime())
			self.clock.setStartTime(t.getCurrentTime())
		#manda a ejecutar un hilo que consultara el tiempo
		self.clock.start()
开发者ID:rodrigoCastroReyes,项目名称:RSS-Reader,代码行数:11,代码来源:RssGUI.py

示例7: get_timestats_string

 def get_timestats_string(self):
     """Return portion of statistics string dealing with time"""
     timelist = []
     if self.StartTime is not None:
         timelist.append("StartTime %.2f (%s)\n" % (self.StartTime, Time.timetopretty(self.StartTime)))
     if self.EndTime is not None:
         timelist.append("EndTime %.2f (%s)\n" % (self.EndTime, Time.timetopretty(self.EndTime)))
     if self.ElapsedTime or (self.StartTime is not None and self.EndTime is not None):
         if self.ElapsedTime is None:
             self.ElapsedTime = self.EndTime - self.StartTime
         timelist.append("ElapsedTime %.2f (%s)\n" % (self.ElapsedTime, Time.inttopretty(self.ElapsedTime)))
     return "".join(timelist)
开发者ID:Christoph-D,项目名称:rdiff-backup,代码行数:12,代码来源:statistics.py

示例8: Compare

def Compare(compare_type, src_rp, dest_rp, compare_time = None):
	"""Compare metadata in src_rp with metadata of backup session

	Prints to stdout whenever a file in the src_rp directory has
	different metadata than what is recorded in the metadata for the
	appropriate session.

	Session time is read from restore_timestr if compare_time is None.

	"""
	global return_val
	dest_rp = require_root_set(dest_rp, 1)
	if not compare_time:
		try: compare_time = Time.genstrtotime(restore_timestr)
		except Time.TimeException, exc: Log.FatalError(str(exc))

	mirror_rp = restore_root.new_index(restore_index)
	inc_rp = Globals.rbdir.append_path("increments", restore_index)
	backup_set_select(src_rp) # Sets source rorp iterator
	if compare_type == "compare": compare_func = compare.Compare
	elif compare_type == "compare-hash": compare_func = compare.Compare_hash
	else:
		assert compare_type == "compare-full", compare_type
		compare_func = compare.Compare_full
	return_val = compare_func(src_rp, mirror_rp, inc_rp, compare_time)
开发者ID:blackcoffeerider,项目名称:rdiff-backup,代码行数:25,代码来源:Main.py

示例9: yield_metadata

def yield_metadata():
	"""Iterate rorps from metadata file, if any are available"""
	metadata.SetManager()
	metadata_iter = metadata.ManagerObj.GetAtTime(regress_time)
	if metadata_iter: return metadata_iter
	log.Log.FatalError("No metadata for time %s (%s) found,\ncannot regress"
					   % (Time.timetopretty(regress_time), regress_time))
开发者ID:Christoph-D,项目名称:rdiff-backup,代码行数:7,代码来源:regress.py

示例10: triple_to_line

	def triple_to_line(triple):
		"""Convert triple to display string"""
		time, size, cum_size = triple
		return "%24s   %13s   %15s" % \
			   (Time.timetopretty(time),
				stat_obj.get_byte_summary_string(size),
				stat_obj.get_byte_summary_string(cum_size))
开发者ID:Christoph-D,项目名称:rdiff-backup,代码行数:7,代码来源:manage.py

示例11: describe_incs_human

def describe_incs_human(incs, mirror_time, mirrorrp):
	"""Return a string describing all the the root increments"""
	incpairs = [(inc.getinctime(), inc) for inc in incs]
	incpairs.sort()

	result = ["Found %d increments:" % len(incpairs)]
	if Globals.chars_to_quote:
		for time, inc in incpairs:
			result.append("    %s   %s" %
						  (FilenameMapping.unquote(inc.dirsplit()[1]),
						   Time.timetopretty(time)))
	else:
		for time, inc in incpairs:
			result.append("    %s   %s" %
						  (inc.dirsplit()[1], Time.timetopretty(time)))
	result.append("Current mirror: %s" % Time.timetopretty(mirror_time))
	return "\n".join(result)
开发者ID:Christoph-D,项目名称:rdiff-backup,代码行数:17,代码来源:manage.py

示例12: _writer_helper

	def _writer_helper(self, prefix, flatfileclass, typestr, time):
		"""Used in the get_xx_writer functions, returns a writer class"""
		if time is None: timestr = Time.curtimestr
		else: timestr = Time.timetostring(time)		
		filename = '%s.%s.%s' % (prefix, timestr, typestr)
		rp = Globals.rbdir.append(filename)
		assert not rp.lstat(), "File %s already exists!" % (rp.path,)
		assert rp.isincfile()
		return flatfileclass(rp, 'w', callback = self.add_incrp)
开发者ID:Christoph-D,项目名称:rdiff-backup,代码行数:9,代码来源:metadata.py

示例13: ListAtTime

def ListAtTime(rp):
	"""List files in archive under rp that are present at restoretime"""
	rp = require_root_set(rp, 1)
	try: rest_time = Time.genstrtotime(restore_timestr)
	except Time.TimeException, exc: Log.FatalError(str(exc))
	mirror_rp = restore_root.new_index(restore_index)
	inc_rp = mirror_rp.append_path("increments", restore_index)
	for rorp in rp.conn.restore.ListAtTime(mirror_rp, inc_rp, rest_time):
		print rorp.get_indexpath()
开发者ID:blackcoffeerider,项目名称:rdiff-backup,代码行数:9,代码来源:Main.py

示例14: ListChangedSince

def ListChangedSince(rp):
	"""List all the files under rp that have changed since restoretime"""
	rp = require_root_set(rp, 1)
	try: rest_time = Time.genstrtotime(restore_timestr)
	except Time.TimeException, exc: Log.FatalError(str(exc))
	mirror_rp = restore_root.new_index(restore_index)
	inc_rp = mirror_rp.append_path("increments", restore_index)
	for rorp in rp.conn.restore.ListChangedSince(mirror_rp, inc_rp, rest_time):
		# This is a hack, see restore.ListChangedSince for rationale
		print rorp.index[0]
开发者ID:blackcoffeerider,项目名称:rdiff-backup,代码行数:10,代码来源:Main.py

示例15: Backup

def Backup(rpin, rpout):
	"""Backup, possibly incrementally, src_path to dest_path."""
	global incdir
	SetConnections.BackupInitConnections(rpin.conn, rpout.conn)
	backup_check_dirs(rpin, rpout)
	backup_set_rbdir(rpin, rpout)
	rpout.conn.fs_abilities.backup_set_globals(rpin, force)
	if Globals.chars_to_quote: rpout = backup_quoted_rpaths(rpout)
	init_user_group_mapping(rpout.conn)
	backup_final_init(rpout)
	backup_set_select(rpin)
	backup_warn_if_infinite_regress(rpin, rpout)
	if prevtime:
		Time.setprevtime(prevtime)
		rpout.conn.Main.backup_touch_curmirror_local(rpin, rpout)
		backup.Mirror_and_increment(rpin, rpout, incdir)
		rpout.conn.Main.backup_remove_curmirror_local()
	else:
		backup.Mirror(rpin, rpout)
		rpout.conn.Main.backup_touch_curmirror_local(rpin, rpout)
开发者ID:Christoph-D,项目名称:rdiff-backup,代码行数:20,代码来源:Main.py


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