Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42408
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-03-31 14:06 -0700 |
| References | <37f23623-8bf5-421a-ab6a-34ff622c69f1@googlegroups.com> <mailman.4027.1364762359.2939.python-list@python.org> |
| Subject | Re: Help with python code! |
| From | jojo <gerrymcgovern@gmail.com> |
| Message-ID | <mailman.4028.1364763983.2939.python-list@python.org> (permalink) |
On Sunday, March 31, 2013 4:39:11 PM UTC-4, Chris Angelico wrote:
> On Mon, Apr 1, 2013 at 7:10 AM, jojo wrote:
>
> > Im used to C# so the syntax looks bizarre to me! Any help would be great.
>
>
>
> The first thing you'll need to understand about Python syntax is that
>
> indentation is important. By posting this code flush-left, you've
>
> actually destroyed its block structure. Could you post it again, with
>
> indentation, please? We'd then be in a much better position to help.
>
>
>
> Chris Angelico
Hi Chris, thanks for your reply. See code below...
import time
import glob
import re
import os
current_time = time.time() + 60*60+24*30
dirList = glob.glob('\content\paytek\ejbProperties\cybersource\*.crt')
q = re.compile('^Owner:.*CN=([^\s\,]+)')
p = re.compile('until: (\w+) (\w+) (\d+) (\d+):(\d+):(\d+) \w+ (\d+)')
cert_name = ""
days = {"Mon":0, "Tue":1, "Wed":2, "Thu":3, "Fri":4, "Sat":5, "Sun":6}
months = {"Jan":1, "Feb":2, "Mar":3, "Apr":4,
"May":5, "Jun":6, "Jul":7, "Aug":8,
"Sep":9, "Oct":10, "Nov":11, "Dec":12}
for fname in dirList:
cmd = "keytool printcert file " + fname
for line in os.popen(cmd).readlines():
line = line.rstrip()
m = p.search(line)
if m:
sue = time.mktime(
(int(m.group(7)), int(months[m.group(2)]), int(m.group(3)),
int(m.group(4)), int(m.group(5)), int(m.group(6)),
int(days[m.group(1)]), 0, 0)
)
expire_time = (sue current_time)/60/60/24
if expire_time < 0:
print cert_name + " has already expired!"
elif expire_time < 31:
print cert_name + " expires in " +str(int(expire_time)) + " days"
else:
m = q.search(line)
if m:
cert_name = m.group(1)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Help with python code! jojo <gerrymcgovern@gmail.com> - 2013-03-31 13:10 -0700
Re: Help with python code! Chris Angelico <rosuav@gmail.com> - 2013-04-01 07:39 +1100
Re: Help with python code! jojo <gerrymcgovern@gmail.com> - 2013-03-31 14:06 -0700
Re: Help with python code! Roy Smith <roy@panix.com> - 2013-03-31 17:13 -0400
Re: Help with python code! jojo <gerrymcgovern@gmail.com> - 2013-03-31 14:21 -0700
Re: Help with python code! Roy Smith <roy@panix.com> - 2013-03-31 17:27 -0400
Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:32 -0700
Re: Help with python code! Alister <alister.ware@ntlworld.com> - 2013-04-01 17:54 +0000
Re: Help with python code! rurpy@yahoo.com - 2013-03-31 14:46 -0700
Re: Help with python code! Chris Angelico <rosuav@gmail.com> - 2013-04-01 08:35 +1100
Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:41 -0700
Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:41 -0700
Re: Help with python code! Jason Friedman <jsf80238@gmail.com> - 2013-04-02 21:59 -0600
Re: Help with python code! Chris Angelico <rosuav@gmail.com> - 2013-04-01 08:21 +1100
Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:24 -0700
Re: Help with python code! gerrymcgovern@gmail.com - 2013-03-31 14:24 -0700
Re: Help with python code! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-31 23:02 +0100
Re: Help with python code! Chris Angelico <rosuav@gmail.com> - 2013-04-01 09:04 +1100
Re: Help with python code! jojo <gerrymcgovern@gmail.com> - 2013-03-31 14:06 -0700
Re: Help with python code! Roy Smith <roy@panix.com> - 2013-03-31 17:08 -0400
csiph-web