Python time.asctime() Examples

The following are 30 code examples of time.asctime(). 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 also want to check out all available functions/classes of the module time , or try the search function .
Example #1
Source File: python多线程ssh爆破.py    From fuzzdb-collect with GNU General Public License v3.0 8 votes vote down vote up
def run(self):
        print("Start try ssh => %s" % self.ip)
        username = "root"
        try:
            password = open(self.dict).read().split('\n')
        except:
            print("Open dict file `%s` error" % self.dict)
            exit(1)
        for pwd in password:
            try:
                ssh = paramiko.SSHClient()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh.connect(self.ip, self.port, username, pwd, timeout = self.timeout)
                print("\nIP => %s, Login %s => %s \n" % (self.ip, username, pwd))
                open(self.LogFile, "a").write("[ %s ] IP => %s, port => %d, %s => %s \n" % (time.asctime( time.localtime(time.time()) ), self.ip, self.port, username, pwd))
                break
            except:
                print("IP => %s, Error %s => %s" % (self.ip, username, pwd))
                pass 
Example #2
Source File: mdi_pychecker.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def doSearch(self):
        self.dp = dirpath(self.dirpattern, self.recurse)
        self.SetTitle("Pychecker Run '%s' (options: %s)" % (self.filpattern, self.greppattern))
        #self.text = []
        self.GetFirstView().Append('#Pychecker Run in '+self.dirpattern+'  %s\n'%time.asctime())
        if self.verbose:
            self.GetFirstView().Append('#   ='+repr(self.dp.dirs)+'\n')
        self.GetFirstView().Append('# Files   '+self.filpattern+'\n')
        self.GetFirstView().Append('# Options '+self.greppattern+'\n')
        self.fplist = self.filpattern.split(';')
        self.GetFirstView().Append('# Running...  ( double click on result lines in order to jump to the source code ) \n')
        win32ui.SetStatusText("Pychecker running.  Please wait...", 0)
        self.dpndx = self.fpndx = 0
        self.fndx = -1
        if not self.dp:
            self.GetFirstView().Append("# ERROR: '%s' does not resolve to any search locations" % self.dirpattern)
            self.SetModifiedFlag(0)
        else:
            ##self.flist = glob.glob(self.dp[0]+'\\'+self.fplist[0])
            import operator
            self.flist = reduce(operator.add, list(map(glob.glob,self.fplist)) )
            #import pywin.debugger;pywin.debugger.set_trace()
            self.startPycheckerRun() 
Example #3
Source File: mailbox.py    From BinderFilter with MIT License 6 votes vote down vote up
def _install_message(self, message):
        """Format a message and blindly write to self._file."""
        from_line = None
        if isinstance(message, str) and message.startswith('From '):
            newline = message.find('\n')
            if newline != -1:
                from_line = message[:newline]
                message = message[newline + 1:]
            else:
                from_line = message
                message = ''
        elif isinstance(message, _mboxMMDFMessage):
            from_line = 'From ' + message.get_from()
        elif isinstance(message, email.message.Message):
            from_line = message.get_unixfrom()  # May be None.
        if from_line is None:
            from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime())
        start = self._file.tell()
        self._file.write(from_line + os.linesep)
        self._dump_message(message, self._file, self._mangle_from_)
        stop = self._file.tell()
        return (start, stop) 
Example #4
Source File: setup.py    From mmdetection with Apache License 2.0 6 votes vote down vote up
def write_version_py():
    content = """# GENERATED VERSION FILE
# TIME: {}

__version__ = '{}'
short_version = '{}'
version_info = ({})
"""
    sha = get_hash()
    with open('mmdet/VERSION', 'r') as f:
        SHORT_VERSION = f.read().strip()
    VERSION_INFO = ', '.join(SHORT_VERSION.split('.'))
    VERSION = SHORT_VERSION + '+' + sha

    version_file_str = content.format(time.asctime(), VERSION, SHORT_VERSION,
                                      VERSION_INFO)
    with open(version_file, 'w') as f:
        f.write(version_file_str) 
Example #5
Source File: canonicalize.py    From pybel with MIT License 6 votes vote down vote up
def _to_bel_lines_header(graph) -> Iterable[str]:
    """Iterate the lines of a BEL graph's corresponding BEL script's header.

    :param pybel.BELGraph graph: A BEL graph
    """
    yield '# This document was created by PyBEL v{} and bel-resources v{} on {}\n'.format(
        VERSION, bel_resources.constants.VERSION, time.asctime(),
    )
    yield from make_knowledge_header(
        namespace_url=graph.namespace_url,
        namespace_patterns=graph.namespace_pattern,
        annotation_url=graph.annotation_url,
        annotation_patterns=graph.annotation_pattern,
        annotation_list=graph.annotation_list,
        **graph.document,
    ) 
Example #6
Source File: ch05_listing_source.py    From https---github.com-josiahcarlson-redis-in-action with MIT License 6 votes vote down vote up
def log_recent(conn, name, message, severity=logging.INFO, pipe=None):
    severity = str(SEVERITY.get(severity, severity)).lower()    #B
    destination = 'recent:%s:%s'%(name, severity)               #C
    message = time.asctime() + ' ' + message                    #D
    pipe = pipe or conn.pipeline()                              #E
    pipe.lpush(destination, message)                            #F
    pipe.ltrim(destination, 0, 99)                              #G
    pipe.execute()                                              #H
# <end id="recent_log"/>
#A Set up a mapping that should help turn most logging severity levels into something consistent
#B Actually try to turn a logging level into a simple string
#C Create the key that messages will be written to
#D Add the current time so that we know when the message was sent
#E Set up a pipeline so we only need 1 round trip
#F Add the message to the beginning of the log list
#G Trim the log list to only include the most recent 100 messages
#H Execute the two commands
#END

# <start id="common_log"/> 
Example #7
Source File: v2rayMS_Server.py    From v2rayMS with MIT License 6 votes vote down vote up
def init_sqlconn(i, source):
    mark = True
    while mark:
        print(
            source + ':' + time.asctime(time.localtime(time.time())) + ':',
            end='')
        try:
            conn = v2server.sqlconn()
            if i == 0:
                print('Mysql Connection Successfully')
            elif i == 1:
                print('Mysql Connection Successfully Recovered')
            mark = False
        except Exception:
            print('Mysql Connection Error')
            time.sleep(10)
            continue
    return conn


# AES模块 
Example #8
Source File: we.py    From wepy with Apache License 2.0 6 votes vote down vote up
def __init__(self, data):
        weather = data['weather'][0]
        self.id = weather['id']
        self.main = weather['main']

        if len(weather['description']) >= 16:
            self.description = weather['description'][0:16]
        else:
            self.description = weather['description']

        if self.id in WEATHER_MAPE:
            self.weather_icon = copy.deepcopy(WEATHER_ICON[WEATHER_MAPE[self.id]])
        else:
            self.weather_icon = copy.deepcopy(WEATHER_ICON['unknown'])

        self.dt = data['dt']
        self.date = time.asctime(time.localtime(self.dt))[0:10]
        self.data = data 
Example #9
Source File: put_test.py    From BerePi with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def helpmsg():
    volubility = len(sys.argv)
    # merge list word items to one string line
    _stringargv = " ".join(sys.argv)

    print "\n  ********************************************** "
    print   "  *** TEST OpenTSDB put                      *** "
    print   "  ***                             By 3POKang *** "
    print   "  ********************************************** "

    timestamp=time.localtime()

    print "  Thanks for the try, time : ", time.asctime(timestamp) , \
    " >> Volubility, Arg length = ", volubility

    if volubility > 1:
        argv1 = sys.argv[1]
        print "  sys.argv[%d] = %s" % (1, argv1) ,
    else :
        exit ("  you should input the IP address of openTSDB server like 10.0.0.1:4242")

    return argv1 
Example #10
Source File: mailbox.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def _install_message(self, message):
        """Format a message and blindly write to self._file."""
        from_line = None
        if isinstance(message, str) and message.startswith('From '):
            newline = message.find('\n')
            if newline != -1:
                from_line = message[:newline]
                message = message[newline + 1:]
            else:
                from_line = message
                message = ''
        elif isinstance(message, _mboxMMDFMessage):
            from_line = 'From ' + message.get_from()
        elif isinstance(message, email.message.Message):
            from_line = message.get_unixfrom()  # May be None.
        if from_line is None:
            from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime())
        start = self._file.tell()
        self._file.write(from_line + os.linesep)
        self._dump_message(message, self._file, self._mangle_from_)
        stop = self._file.tell()
        return (start, stop) 
Example #11
Source File: vssutil.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def SubstituteVSSInFile(projectName, inName, outName):
	import win32api
	if win32api.GetFullPathName(inName)==win32api.GetFullPathName(outName):
		raise RuntimeError("The input and output filenames can not be the same")
	sourceSafe=GetSS()
	project = sourceSafe.VSSItem(projectName)
	# Find the last label
	label = None
	for version in project.Versions:
		if version.Label:
			break
	else:
		print "Couldnt find a label in the sourcesafe project!"
		return
	# Setup some local helpers for the conversion strings.
	vss_label = version.Label
	vss_date = time.asctime(time.localtime(int(version.Date)))
	now = time.asctime(time.localtime(time.time()))
	SubstituteInFile(inName, outName, (locals(),globals())) 
Example #12
Source File: vssutil.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def VssLog(project, linePrefix = "", noLabels = 5, maxItems=150):
	lines = []
	num = 0
	labelNum = 0
	for i in project.GetVersions(constants.VSSFLAG_RECURSYES):
		num = num + 1
		if num > maxItems : break
		commentDesc = itemDesc = ""
		if i.Action[:5]=="Added":
			continue
		if len(i.Label):
			labelNum = labelNum + 1
			itemDesc = i.Action
		else:
			itemDesc = i.VSSItem.Name
			if str(itemDesc[-4:])==".dsp":
				continue
		if i.Comment:
			commentDesc ="\n%s\t%s" % (linePrefix, i.Comment)
		lines.append("%s%s\t%s%s" % (linePrefix, time.asctime(time.localtime(int(i.Date))), itemDesc, commentDesc))
		if labelNum > noLabels:
			break
	return string.join(lines,"\n") 
Example #13
Source File: mailbox.py    From meddle with MIT License 6 votes vote down vote up
def _install_message(self, message):
        """Format a message and blindly write to self._file."""
        from_line = None
        if isinstance(message, str) and message.startswith('From '):
            newline = message.find('\n')
            if newline != -1:
                from_line = message[:newline]
                message = message[newline + 1:]
            else:
                from_line = message
                message = ''
        elif isinstance(message, _mboxMMDFMessage):
            from_line = 'From ' + message.get_from()
        elif isinstance(message, email.message.Message):
            from_line = message.get_unixfrom()  # May be None.
        if from_line is None:
            from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime())
        start = self._file.tell()
        self._file.write(from_line + os.linesep)
        self._dump_message(message, self._file, self._mangle_from_)
        stop = self._file.tell()
        return (start, stop) 
Example #14
Source File: nfp_process.py    From nightmare with GNU General Public License v2.0 5 votes vote down vote up
def do_nothing():
  try:
    import time
    print time.asctime()
    time.sleep(1)
  except KeyboardInterrupt:
    print "Aborted." 
Example #15
Source File: find_samples.py    From nightmare with GNU General Public License v2.0 5 votes vote down vote up
def log(msg):
  print "[%s] %s" % (time.asctime(), msg)

#----------------------------------------------------------------------- 
Example #16
Source File: simple_log.py    From maltindex with GNU General Public License v2.0 5 votes vote down vote up
def log(msg):
  print "[%s %d:%d] %s" % (time.asctime(), os.getpid(), thread.get_ident(), msg)
  sys.stdout.flush()

#----------------------------------------------------------------------- 
Example #17
Source File: pyshpLargeWriter.py    From Learn with MIT License 5 votes vote down vote up
def progress(last, count, total):
  """Print percent completed"""
  percent = int((count/(total*1.0))*100.0)
  if percent % 10.0 == 0 and percent > last:
    print "%s %% done - Shape %s/%s at %s" % (percent, count, total, time.asctime())
  return percent  


# Create a large shapefile writer with
# a filname and a shapefile type.
# 1=Point, 5=Polygon 
Example #18
Source File: test_time.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_asctime(self):
        self.assertEqual(time.asctime((2009, 9, 4, 14, 57, 11, 4, 247, 0)), 'Fri Sep 04 14:57:11 2009')
        self.assertEqual(time.asctime((2009, 9, 4, 14, 57, 11, 4, 247, 1)), 'Fri Sep 04 14:57:11 2009')
        self.assertEqual(time.asctime((2009, 9, 4, 14, 57, 11, 4, 247, -1)), 'Fri Sep 04 14:57:11 2009') 
Example #19
Source File: nfp_log.py    From nightmare with GNU General Public License v2.0 5 votes vote down vote up
def log(msg):
  print "[%s %d:%d] %s" % (time.asctime(), os.getpid(), thread.get_ident(), msg)
  sys.stdout.flush()

#----------------------------------------------------------------------- 
Example #20
Source File: test_mailbox.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_maildir_to_mboxmmdf(self):
        # Convert MaildirMessage to mboxmessage and MMDFMessage
        pairs = (('D', ''), ('F', 'F'), ('P', ''), ('R', 'A'), ('S', 'R'),
                 ('T', 'D'), ('DFPRST', 'RDFA'))
        for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
            msg_maildir = mailbox.MaildirMessage(_sample_message)
            msg_maildir.set_date(0.0)
            for setting, result in pairs:
                msg_maildir.set_flags(setting)
                msg = class_(msg_maildir)
                self.assertEqual(msg.get_flags(), result)
                self.assertEqual(msg.get_from(), 'MAILER-DAEMON %s' %
                                 time.asctime(time.gmtime(0.0)))
            msg_maildir.set_subdir('cur')
            self.assertEqual(class_(msg_maildir).get_flags(), 'RODFA') 
Example #21
Source File: test_time.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_asctime(self):
        time.asctime(time.gmtime(self.t))
        self.assertRaises(TypeError, time.asctime, 0)
        self.assertRaises(TypeError, time.asctime, ())

        # Max year is only limited by the size of C int.
        asc = time.asctime((TIME_MAXYEAR, 6, 1) + (0,) * 6)
        self.assertEqual(asc[-len(str(TIME_MAXYEAR)):], str(TIME_MAXYEAR))
        self.assertRaises(OverflowError, time.asctime,
                          (TIME_MAXYEAR + 1,) + (0,) * 8)
        self.assertRaises(TypeError, time.asctime, 0)
        self.assertRaises(TypeError, time.asctime, ())
        self.assertRaises(TypeError, time.asctime, (0,) * 10) 
Example #22
Source File: test_time.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_conversions(self):
        self.assertTrue(time.ctime(self.t)
                     == time.asctime(time.localtime(self.t)))
        self.assertTrue(long(time.mktime(time.localtime(self.t)))
                     == long(self.t)) 
Example #23
Source File: mailbox.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def set_from(self, from_, time_=None):
        """Set "From " line, formatting and appending time_ if specified."""
        if time_ is not None:
            if time_ is True:
                time_ = time.gmtime()
            from_ += ' ' + time.asctime(time_)
        self._from = from_ 
Example #24
Source File: test_time.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_conversions(self):
        self.assertTrue(time.ctime(self.t)
                     == time.asctime(time.localtime(self.t)))
        self.assertTrue(long(time.mktime(time.localtime(self.t)))
                     == long(self.t)) 
Example #25
Source File: test_time.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_asctime(self):
        time.asctime(time.gmtime(self.t))
        self.assertRaises(TypeError, time.asctime, 0)
        self.assertRaises(TypeError, time.asctime, ())
        # XXX: Posix compiant asctime should refuse to convert
        # year > 9999, but Linux implementation does not.
        # self.assertRaises(ValueError, time.asctime,
        #                  (12345, 1, 0, 0, 0, 0, 0, 0, 0))
        # XXX: For now, just make sure we don't have a crash:
        try:
            time.asctime((12345, 1, 1, 0, 0, 0, 0, 1, 0))
        except ValueError:
            pass 
Example #26
Source File: mio5.py    From Computable with MIT License 5 votes vote down vote up
def write_file_header(self):
        # write header
        hdr = np.zeros((), NDT_FILE_HDR)
        hdr['description'] = 'MATLAB 5.0 MAT-file Platform: %s, Created on: %s' \
            % (os.name,time.asctime())
        hdr['version'] = 0x0100
        hdr['endian_test'] = np.ndarray(shape=(),
                                      dtype='S2',
                                      buffer=np.uint16(0x4d49))
        self.file_stream.write(hdr.tostring()) 
Example #27
Source File: pswriter.py    From pyx with GNU General Public License v2.0 5 votes vote down vote up
def writeinfo(self, file):
        if os.environ.get('SOURCE_DATE_EPOCH'):
            creation_date = time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH')))
        else:
            creation_date = time.localtime()
        file.write("%%%%Creator: PyX %s\n" % version.version)
        if self.title is not None:
            file.write("%%%%Title: %s\n" % self.title)
        file.write("%%%%CreationDate: %s\n" %
                   time.asctime(creation_date)) 
Example #28
Source File: start.py    From Starx_Pixiv_Collector with MIT License 5 votes vote down vote up
def print_with_tag(tag, data ,debug=0):
    data_print = data
    if type(data) == list:
        data_print = ''
        for per_data in data:
            if len(data_print) == 0:
                data_print += str(per_data)
            else:
                data_print += ' ' + str(per_data)
    if debug == 1:
        print('[' + time.asctime(time.localtime(time.time())) + '] ' + tag + ' =>', data_print)
    else:
        print(data_print) 
Example #29
Source File: mio5.py    From lambda-packs with MIT License 5 votes vote down vote up
def write_file_header(self):
        # write header
        hdr = np.zeros((), NDT_FILE_HDR)
        hdr['description'] = 'MATLAB 5.0 MAT-file Platform: %s, Created on: %s' \
            % (os.name,time.asctime())
        hdr['version'] = 0x0100
        hdr['endian_test'] = np.ndarray(shape=(),
                                      dtype='S2',
                                      buffer=np.uint16(0x4d49))
        self.file_stream.write(hdr.tostring()) 
Example #30
Source File: mailbox.py    From BinderFilter with MIT License 5 votes vote down vote up
def set_from(self, from_, time_=None):
        """Set "From " line, formatting and appending time_ if specified."""
        if time_ is not None:
            if time_ is True:
                time_ = time.gmtime()
            from_ += ' ' + time.asctime(time_)
        self._from = from_