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


Groups > de.comp.lang.python > #5909

Re: [Python-de] Re: Funktion ueberschreiben?

Path csiph.com!weretis.net!feeder8.news.weretis.net!news.datentrampelpfad.de!thinkmo.de!news.uni-stuttgart.de!.POSTED!not-for-mail
From Ulli Horlacher <framstag@rus.uni-stuttgart.de>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] Re: Funktion ueberschreiben?
Date Mon, 5 Dec 2022 08:24:37 +0000 (UTC)
Organization University of Stuttgart, FRG
Lines 88
Message-ID <tmk9s5$cjb$2@news2.informatik.uni-stuttgart.de> (permalink)
References <tmf1b2$9jn$1@news2.informatik.uni-stuttgart.de> <f7a2f3e9-9848-9f5e-5761-efb0b41bb181@python-academy.de> <tmfr0o$9vg$1@news2.informatik.uni-stuttgart.de> <dc686a23-6270-f634-7358-c1aa10d74b4b@chrisarndt.de> <tmfv45$a1a$1@news2.informatik.uni-stuttgart.de> <slrntonpdo.13t6p.hjp-usenet3@trintignant.hjp.at> <tmhr2q$b5c$1@news2.informatik.uni-stuttgart.de> <slrntop5ri.15dl6.hjp-usenet3@trintignant.hjp.at> <tmi67a$bbs$1@news2.informatik.uni-stuttgart.de> <slrntop96d.15lbp.hjp-usenet3@trintignant.hjp.at> <tmibi1$be9$1@news2.informatik.uni-stuttgart.de> <slrntoq30h.t9b.hjp-usenet3@trintignant.hjp.at> <tmk8rp$cjb$1@news2.informatik.uni-stuttgart.de>
X-Trace news2.informatik.uni-stuttgart.de 1670228677 12907 129.69.1.129 (5 Dec 2022 08:24:37 GMT)
X-Complaints-To news@news.uni-stuttgart.de
NNTP-Posting-Date Mon, 5 Dec 2022 08:24:37 +0000 (UTC)
User-Agent tin/2.4.5-20200522 ("Millburn") (Linux/5.4.0-135-generic (x86_64))
Xref csiph.com de.comp.lang.python:5909

Show key headers only | View raw


Ulli Horlacher <framstag@rus.uni-stuttgart.de> wrote:

> --- Start running command LIST at 08:57:10.534 ---
> Traceback (innermost last):
>   File "<string>", line 106, in <module>
>   File "<string>", line 92, in with_tempdir
>   File "/usr/lib/python3/dist-packages/duplicity/dup_main.py", line 1538, in main
>     do_backup(action)
>   File "/usr/lib/python3/dist-packages/duplicity/dup_main.py", line 1558, in do_backup
>     col_stats = dup_collections.CollectionsStatus(globals.backend,
>   File "/usr/lib/python3/dist-packages/duplicity/dup_collections.py", line 744, in set_values
>     self.get_backup_chains(partials + backend_filename_list)
>   File "/usr/lib/python3/dist-packages/duplicity/dup_collections.py", line 896, in get_backup_chains
>     add_to_chains(s)
>   File "/usr/lib/python3/dist-packages/duplicity/dup_collections.py", line 884, in add_to_chains
>     log.Debug(_(u"Found backup chain %s") % (new_chain.short_desc()))
>   File "/usr/lib/python3/dist-packages/duplicity/dup_collections.py", line 408, in short_desc
>     return u"[%s]-[%s]" % (dup_time.timetopretty(self.start_time),
>   File "/usr/lib/python3/dist-packages/duplicity/dup_time.py", line 169, in timetopretty
>     return time.asctime(time.localtime(timeinseconds))
>   File "/opt/s3tik/bin/duplicity", line 6, in isodate
>     return time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(timeinseconds))
>  TypeError: an integer is required (got type time.struct_time)
> 
> 08:57:10.886 Task 'LIST' failed with exit code '30'.
> --- Finished state FAILED 'code 30' at 08:57:10.886 - Runtime 00:00:00.351 ---
> 
> root@obertux:/opt/s3tik/bin# cat duplicity
> #!/usr/bin/python3
> 
> import time
> 
> def isodate(timeinseconds):
>   return time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(timeinseconds))
> 
> time.asctime = isodate;
> 
> with open("/usr/bin/duplicity") as duplicity:
>     code = duplicity.read()
>     exec(code)

Habs nun geaendert zu:

root@obertux:/opt/s3tik/bin# cat duplicity
#!/usr/bin/python3

from duplicity import dup_time

def isodate(timeinseconds):
  return time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(timeinseconds))

dup_time.timetopretty = isodate;

with open("/usr/bin/duplicity") as duplicity:
    code = duplicity.read()
    exec(code)


Ich definiere also nicht time.asctime() um, sondern dup_time.timetopretty()
Ist eh besser.
Und DAMIT funktioniert es:

root@obertux:/opt/s3tik/bin# duply root list | tail 
2021-01-20 17:55:59 server/tacitus
2021-01-20 17:55:59 server/unifex
2021-01-20 17:56:00 server/zentux
2021-01-20 17:56:00 server/zoo
2022-12-03 06:57:02 tmp
2022-12-03 09:43:51 tmp/.zz
2015-04-28 15:08:50 vcli
2013-09-11 17:02:36 vminfo_example
2013-06-24 13:33:40 vmti
--- Finished state OK at 09:17:08.178 - Runtime 00:00:01.087 ---


==> Ich bekomme jetzt ISO Datum!

Und ich weiss nun, wie man Python-Programmen geaenderte Funktionen
unterschieben kann, ohne den Original Source Code aendern zu muessen.
Den Trick kann ich spaeter bestimmt noch oefters gebrauchen!
Sehr gut!

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/

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


Thread

Funktion ueberschreiben? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2022-12-03 08:28 +0000
  [Python-de] Re: Funktion ueberschreiben? Mike Müller <mmueller@python-academy.de> - 2022-12-03 10:00 +0100
    [Python-de] Re: Funktion ueberschreiben? Mike Müller <mmueller@python-academy.de> - 2022-12-03 13:49 +0100
    Re: [Python-de] Re: Funktion ueberschreiben? "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2022-12-03 14:27 +0100
    Re: [Python-de] Re: Funktion ueberschreiben? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2022-12-03 15:46 +0000
      [Python-de] Re: Funktion ueberschreiben? Christopher Arndt <chris@chrisarndt.de> - 2022-12-03 16:57 +0100
        Re: [Python-de] Re: Funktion ueberschreiben? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2022-12-03 16:56 +0000
          Re: [Python-de] Re: Funktion ueberschreiben? "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2022-12-04 01:11 +0100
            Re: [Python-de] Re: Funktion ueberschreiben? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2022-12-04 09:59 +0000
              Re: [Python-de] Re: Funktion ueberschreiben? "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2022-12-04 13:49 +0100
                Re: [Python-de] Re: Funktion ueberschreiben? "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2022-12-04 14:06 +0100
                Re: [Python-de] Re: Funktion ueberschreiben? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2022-12-04 13:10 +0000
                Re: [Python-de] Re: Funktion ueberschreiben? "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2022-12-04 14:46 +0100
                Re: [Python-de] Re: Funktion ueberschreiben? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2022-12-04 14:41 +0000
                Re: [Python-de] Re: Funktion ueberschreiben? "Peter J. Holzer" <hjp-usenet3@hjp.at> - 2022-12-04 22:07 +0100
                Re: [Python-de] Re: Funktion ueberschreiben? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2022-12-05 08:07 +0000
                Re: [Python-de] Re: Funktion ueberschreiben? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2022-12-05 08:24 +0000
      Re: [Python-de] Re: Funktion ueberschreiben? "Peter Heitzer" <peter.heitzer@rz.uni-regensburg.de> - 2022-12-05 08:59 +0000

csiph-web