Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86020

Re: subprocess command fails

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'error:': 0.07; 'sys': 0.07; 'string': 0.09; 'brad': 0.09; 'parsing': 0.09; 'subject:command': 0.09; 'adjustment': 0.16; 'all?': 0.16; 'fingerprints': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'simpson': 0.16; 'skip:> 20': 0.16; 'str,': 0.16; 'strftime': 0.16; 'subject:fails': 0.16; 'wrote:': 0.18; 'import': 0.22; 'header:User-Agent:1': 0.23; 'cheers,': 0.24; '15,': 0.26; 'header:In-Reply-To:1': 0.27; 'file': 0.32; '(most': 0.33; 'skip:d 20': 0.34; 'but': 0.35; 'object,': 0.36; 'skip:> 10': 0.36; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'information,': 0.61; 'content-disposition:inline': 0.62; '>from': 0.68; 'wear': 0.68; 'received:192.168.15': 0.84; 'tied': 0.93
Date Sat, 21 Feb 2015 17:47:36 +1100
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: subprocess command fails
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <9edb2725-c91b-4ae2-b5f4-91a80ed3afe8@googlegroups.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <9edb2725-c91b-4ae2-b5f4-91a80ed3afe8@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18950.1424501263.18130.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424501263 news.xs4all.nl 2900 [2001:888:2000:d::a6]:37501
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 3847
X-Received-Body-CRC 3467249399
Xref csiph.com comp.lang.python:86020

Show key headers only | View raw


On 20Feb2015 21:14, Brad s <bcddd214@gmail.com> wrote:
>Time adjustment error:
>
># python3.4 timefix.py
>2015022105
>2015-02-21 05:00:00
>Traceback (most recent call last):
>  File "timefix.py", line 15, in <module>
>    ndate = datetime.datetime.strptime(timeadd, '%Y%m%d%H')
>TypeError: must be str, not datetime.datetime
>
>
>
># cat timefix.py
>#!/usr/bin/python3.4
>import subprocess
>import sys
>from datetime import datetime
>import datetime
>from time import gmtime, strftime
>
>pretime = strftime("%Y%m%d%H", gmtime())
>time = datetime.datetime.strptime(pretime,'%Y%m%d%H')
>print(pretime)
>print (time)
>plustime = datetime.timedelta(days=730)
>timeadd = (time + plustime)
>str(timeadd)
>ndate = datetime.datetime.strptime(timeadd, '%Y%m%d%H')
>#timeadd = timeadd.replace(tzinfo=UTC())
>print (timeadd)
>print (ndate)

Well, timeadd is a date object, yes? strptime is for parsing a string for date 
information, but timeadd is already parsed, as it were. Why are you calling 
strptime at all?

Cheers,
Cameron Simpson <cs@zip.com.au>

stomping on roses and strangling kittens
    leaving no fingerprints cause we wear mittens
    inflatable prostitutes tied up with strings
    these are a few of my favorite things
        - gypsy <gypsy@popeet!c3.com>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 15:30 -0800
  Re: subprocess command fails Cameron Simpson <cs@zip.com.au> - 2015-02-21 12:11 +1100
  Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 20:47 -0800
    Re: subprocess command fails Larry Hudson <orgnut@yahoo.com> - 2015-02-21 12:33 -0800
  Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 21:14 -0800
    Re: subprocess command fails Cameron Simpson <cs@zip.com.au> - 2015-02-21 17:47 +1100
  Re: subprocess command fails Brad s <bcddd214@gmail.com> - 2015-02-20 22:41 -0800

csiph-web