Python time.ctime() Examples
The following are 30 code examples for showing how to use time.ctime(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
time
, or try the search function
.
Example 1
Project: aospy Author: spencerahill File: calc.py License: Apache License 2.0 | 6 votes |
def load(self, dtype_out_time, dtype_out_vert=False, region=False, plot_units=False, mask_unphysical=False): """Load the data from the object if possible or from disk.""" msg = ("Loading data from disk for object={0}, dtype_out_time={1}, " "dtype_out_vert={2}, and region=" "{3}".format(self, dtype_out_time, dtype_out_vert, region)) logging.info(msg + ' ({})'.format(ctime())) # Grab from the object if its there. try: data = self.data_out[dtype_out_time] except (AttributeError, KeyError): # Otherwise get from disk. Try scratch first, then archive. try: data = self._load_from_disk(dtype_out_time, dtype_out_vert, region=region) except IOError: data = self._load_from_tar(dtype_out_time, dtype_out_vert) # Copy the array to self.data_out for ease of future access. self._update_data_out(data, dtype_out_time) # Apply desired plotting/cleanup methods. if mask_unphysical: data = self.var.mask_unphysical(data) if plot_units: data = self.var.to_plot_units(data, dtype_vert=dtype_out_vert) return data
Example 2
Project: BiblioPixelAnimations Author: ManiacalLabs File: BinaryClock.py License: MIT License | 6 votes |
def step(self, amt=1): self.layout.all_off() a = "" + time.ctime() tIndex = [11, 12, 14, 15, 17, 18] colSize = [2, 4, 3, 4, 3, 4] for x in range(6): b = bin(128 + int(a[tIndex[x]])) for i in range(colSize[x]): is_off = b[6 + (4 - colSize[x]) + i] == '0' color = self.palette(int(is_off)) self.layout.fillRect( self._origX + (x) + (self._lightSize - 1) * x + self._colSpacing * x, ((4 - colSize[x]) + i + self._origY) * self._lightSize, self._lightSize, self._lightSize, color)
Example 3
Project: StructEngPy Author: zhuoju36 File: Logger.py License: MIT License | 6 votes |
def info(log:str,target='console'): """ log: text to record. target: 'console' to print log on screen or file to write in. """ if target=='console': thd=threading.Thread(target=print,args=(ctime(),':',log)) thd.setDaemon(True) thd.start() thd.join() else: try: thd=threading.Thread(target=print,args=(ctime(),':',log)) thd.setDaemon(True) thd.start() thd.join() except Exception as e: print(e)
Example 4
Project: deep-learning-note Author: wdxtub File: 3_thread_wayB.py License: MIT License | 6 votes |
def main(): print('程序开始,当前时间', ctime()) threads = [] nloops = range(len(loops)) for i in nloops: t = MyThread(loop, (i, loops[i])) threads.append(t) for i in nloops: threads[i].start() for i in nloops: threads[i].join() # 等待进程完成 print('程序结束,当前时间', ctime())
Example 5
Project: deep-learning-note Author: wdxtub File: 2_thread_wayA.py License: MIT License | 6 votes |
def main(): print('程序开始,当前时间', ctime()) threads = [] nloops = range(len(loops)) for i in nloops: t = threading.Thread(target=loop, args=(i, loops[i])) threads.append(t) for i in nloops: threads[i].start() for i in nloops: threads[i].join() # 等待进程完成 print('程序结束,当前时间', ctime())
Example 6
Project: deep-learning-note Author: wdxtub File: 4_thread_fac_fib.py License: MIT License | 6 votes |
def main(): nfuncs = range(len(funcs)) print('*** 单线程') for i in nfuncs: print('starting', funcs[i].__name__, 'at:', ctime()) print(funcs[i](n)) print(funcs[i].__name__, 'finished at:', ctime()) print('\n*** 多线程') threads = [] for i in nfuncs: t = MyThread(funcs[i], (n,), funcs[i].__name__) threads.append(t) for i in nfuncs: threads[i].start() for i in nfuncs: threads[i].join() print(threads[i].getResult()) print('ALL DONE')
Example 7
Project: MaliciousMacroBot Author: egaus File: mmbot.py License: MIT License | 6 votes |
def get_file_meta_data(self, filepath, filename=None, getHash=False): """ helper function to get meta information about a file to include it's path, date modified, size :param filepath: path to a file :param filename: filename :param getHash: whether or not the hash should be computed :return: a tuple of format (filename, filepath, filesize, filemodified, md5) """ if filename is None: filename = os.path.split(filepath)[1] filemodified = time.ctime(os.path.getmtime(filepath)) filesize = os.path.getsize(filepath) md5 = np.nan if getHash: md5 = self.get_file_hash(filepath) return (filename, filepath, filesize, filemodified, md5)
Example 8
Project: razzy-spinner Author: rafasashi File: chunkparser_app.py License: GNU General Public License v3.0 | 6 votes |
def save_grammar(self, filename=None): if not filename: ftypes = [('Chunk Gramamr', '.chunk'), ('All files', '*')] filename = tkinter.filedialog.asksaveasfilename(filetypes=ftypes, defaultextension='.chunk') if not filename: return if (self._history and self.normalized_grammar == self.normalize_grammar(self._history[-1][0])): precision, recall, fscore = ['%.2f%%' % (100*v) for v in self._history[-1][1:]] elif self.chunker is None: precision = recall = fscore = 'Grammar not well formed' else: precision = recall = fscore = 'Not finished evaluation yet' with open(filename, 'w') as outfile: outfile.write(self.SAVE_GRAMMAR_TEMPLATE % dict( date=time.ctime(), devset=self.devset_name, precision=precision, recall=recall, fscore=fscore, grammar=self.grammar.strip()))
Example 9
Project: razzy-spinner Author: rafasashi File: weka.py License: GNU General Public License v3.0 | 6 votes |
def header_section(self): """Returns an ARFF header as a string.""" # Header comment. s = ('% Weka ARFF file\n' + '% Generated automatically by NLTK\n' + '%% %s\n\n' % time.ctime()) # Relation name s += '@RELATION rel\n\n' # Input attribute specifications for fname, ftype in self._features: s += '@ATTRIBUTE %-30r %s\n' % (fname, ftype) # Label attribute specification s += '@ATTRIBUTE %-30r {%s}\n' % ('-label-', ','.join(self._labels)) return s
Example 10
Project: PythonClassBook Author: PythonClassRoom File: fig19_15.py License: GNU General Public License v3.0 | 6 votes |
def run( self ): """Vehicle waits unless/until light is green""" # stagger arrival times time.sleep( random.randrange( 1, 10 ) ) # prints arrival time of car at intersection print "%s arrived at %s" % \ ( self.getName(), time.ctime( time.time() ) ) # wait for green light self.threadEvent.wait() # displays time that car departs intersection print "%s passes through intersection at %s" % \ ( self.getName(), time.ctime( time.time() ) )
Example 11
Project: asn1tools Author: eerimoq File: __init__.py License: MIT License | 6 votes |
def generate(compiled, codec): """Generate Rust source code from given compiled specification. """ date = time.ctime() if codec == 'uper': helpers, types_code = uper.generate(compiled) else: raise Exception() source = SOURCE_FMT.format(version=__version__, date=date, helpers=helpers, types_code=types_code) return source
Example 12
Project: PiClock Author: n0bel File: PyQtPiClock.py License: MIT License | 6 votes |
def getwx(): global wxurl global wxreply print "getting current and forecast:" + time.ctime() wxurl = 'https://api.darksky.net/forecast/' + \ ApiKeys.dsapi + \ '/' wxurl += str(Config.location.lat) + ',' + \ str(Config.location.lng) wxurl += '?units=us&lang=' + Config.Language.lower() wxurl += '&r=' + str(random.random()) print wxurl r = QUrl(wxurl) r = QNetworkRequest(r) wxreply = manager.get(r) wxreply.finished.connect(wxfinished)
Example 13
Project: benchmarks Author: tensorflow File: benchmark_cnn.py License: Apache License 2.0 | 6 votes |
def run(self): while self.finish_time == 0: time.sleep(.25) global_step_val, = self.sess.run([self.global_step_op]) if self.start_time == 0 and global_step_val >= self.start_at_global_step: # Use tf.logging.info instead of log_fn, since print (which is log_fn) # is not thread safe and may interleave the outputs from two parallel # calls to print, which can break tests. tf.logging.info('Starting real work at step %s at time %s' % (global_step_val, time.ctime())) self.start_time = time.time() self.start_step = global_step_val if self.finish_time == 0 and global_step_val >= self.end_at_global_step: tf.logging.info('Finishing real work at step %s at time %s' % (global_step_val, time.ctime())) self.finish_time = time.time() self.finish_step = global_step_val
Example 14
Project: rekall Author: google File: xls.py License: GNU General Public License v2.0 | 6 votes |
def __init__(self, output=None, **kwargs): super(XLSRenderer, self).__init__(**kwargs) # Make a single delegate text renderer for reuse. Most of the time we # will just replicate the output from the TextRenderer inside the # spreadsheet cell. self.delegate_text_renderer = text.TextRenderer(session=self.session) self.output = output or self.session.GetParameter("output") # If no output filename was give, just make a name based on the time # stamp. if self.output == None: self.output = "%s.xls" % time.ctime() try: self.wb = openpyxl.load_workbook(self.output) self.current_ws = self.wb.create_sheet() except IOError: self.wb = openpyxl.Workbook() self.current_ws = self.wb.active
Example 15
Project: crawler_examples Author: WiseDoge File: main.py License: Apache License 2.0 | 6 votes |
def crawl(url): """ 从给定的URL中提取出内容,并以列表的形式返回。 """ try: html = requests.get(url) except: with open("log.log","a") as file: file.write("Http error on " + time.ctime()) time.sleep(60) return None soup = BeautifulSoup(html.text, 'lxml') data_list = [] for cont in soup.find_all("div", {"class":"content"}): raw_data = cont.get_text() data = raw_data.replace("\n","") data_list.append(data) return data_list
Example 16
Project: meddle Author: glmcdona File: pstats.py License: MIT License | 6 votes |
def load_stats(self, arg): if not arg: self.stats = {} elif isinstance(arg, basestring): f = open(arg, 'rb') self.stats = marshal.load(f) f.close() try: file_stats = os.stat(arg) arg = time.ctime(file_stats.st_mtime) + " " + arg except: # in case this is not unix pass self.files = [ arg ] elif hasattr(arg, 'create_stats'): arg.create_stats() self.stats = arg.stats arg.stats = {} if not self.stats: raise TypeError, "Cannot create or construct a %r object from '%r''" % ( self.__class__, arg) return
Example 17
Project: meddle Author: glmcdona File: generator.py License: MIT License | 6 votes |
def flatten(self, msg, unixfrom=False): """Print the message object tree rooted at msg to the output file specified when the Generator instance was created. unixfrom is a flag that forces the printing of a Unix From_ delimiter before the first object in the message tree. If the original message has no From_ delimiter, a `standard' one is crafted. By default, this is False to inhibit the printing of any From_ delimiter. Note that for subobjects, no From_ line is printed. """ if unixfrom: ufrom = msg.get_unixfrom() if not ufrom: ufrom = 'From nobody ' + time.ctime(time.time()) print >> self._fp, ufrom self._write(msg)
Example 18
Project: aospy Author: spencerahill File: calc.py License: Apache License 2.0 | 5 votes |
def _print_verbose(*args): """Print diagnostic message.""" try: return '{0} {1} ({2})'.format(args[0], args[1], ctime()) except IndexError: return '{0} ({1})'.format(args[0], ctime())
Example 19
Project: deep-learning-note Author: wdxtub File: 8_prodcons.py License: MIT License | 5 votes |
def _atexit(): print("all done at:", ctime())
Example 20
Project: deep-learning-note Author: wdxtub File: 3_thread_wayB.py License: MIT License | 5 votes |
def loop(nloop, nsec): print('Start LOOP', nloop, 'at:', ctime()) sleep(nsec) print('LOOP', nloop, 'DONE at:', ctime())
Example 21
Project: deep-learning-note Author: wdxtub File: myThread.py License: MIT License | 5 votes |
def run(self): print('starting', self.name, 'at:', ctime()) self.res = self.func(*self.args) print(self.name, 'finished at:', ctime())
Example 22
Project: deep-learning-note Author: wdxtub File: 5_bookrank.py License: MIT License | 5 votes |
def main(): print('At {} on Amazon...'.format(ctime())) for isbn in ISBNs: # use multi thread Thread(target=_showRanking, args=(isbn,)).start()
Example 23
Project: deep-learning-note Author: wdxtub File: 6_thread_wayC.py License: MIT License | 5 votes |
def loop(nsec): myname = currentThread().name with lock: remaining.add(myname) print("[{}] Started {}".format(ctime(), myname)) sleep(nsec) with lock: remaining.remove(myname) print("[{}] Completed {} ({} secs)".format(ctime(), myname, nsec)) print(" (remaining: {})".format(remaining or "None"))
Example 24
Project: deep-learning-note Author: wdxtub File: 6_thread_wayC.py License: MIT License | 5 votes |
def _atexit(): print("all Done at", ctime())
Example 25
Project: deep-learning-note Author: wdxtub File: 1_one_thread.py License: MIT License | 5 votes |
def loop0(): print('开始 Loop 0,当前时间', ctime()) sleep(4) print('Loop 0 结束,当前时间', ctime())
Example 26
Project: deep-learning-note Author: wdxtub File: 1_one_thread.py License: MIT License | 5 votes |
def loop1(): print('开始 Loop 1,当前时间', ctime()) sleep(2) print('Loop 1 结束,当前时间', ctime())
Example 27
Project: deep-learning-note Author: wdxtub File: 1_one_thread.py License: MIT License | 5 votes |
def main(): print('程序开始,当前时间', ctime()) loop0() loop1() print('程序结束,当前时间', ctime())
Example 28
Project: deep-learning-note Author: wdxtub File: 7_candy.py License: MIT License | 5 votes |
def _main(): print("starging at:", ctime()) nloops = randrange(2, 6) print("THE CANDY MACHINE (full with %d bars)!" % MAX) Thread( target=consumer, args=(randrange(nloops, nloops + MAX + 2),) ).start() # buyer Thread(target=producer, args=(nloops,)).start() # vndr
Example 29
Project: deep-learning-note Author: wdxtub File: 7_candy.py License: MIT License | 5 votes |
def _atexit(): print("all done at:", ctime())
Example 30
Project: deep-learning-note Author: wdxtub File: 7_tsTservTW.py License: MIT License | 5 votes |
def dataReceived(self, data): message = '[%s] %s' % (ctime(), data) self.transport.write(message.encode())