Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ HPR3067: Getting my Python3 code working in Python2

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š HPR3067: Getting my Python3 code working in Python2


๐Ÿ’ก Newskategorie: Podcasts
๐Ÿ”— Quelle: hackerpublicradio.org

I have a raspberry Pi model B with the original Pifacecad add on board

I recently upgraded the operating system on my raspberry pi from Wheezy (Debian 7) to Jessie (Debian 8), all seemed fine till I tried to run my Python3 project. It reported that the pifacecad module wasnโ€™t present. I tried to install the module using the standard apt-get command given in the Pifacecad documentation. It installed OK for python 2 but It would not install for python 3 as there was a dependency issue with the python-lirc library. Iโ€™m guessing the upgrade broke something.

I installed a fresh minimal installation of raspbian Stretch (Debian 9) onto a new SD card and ran the standard installation command in the Pifacecad documentation. It all installed but there was a warning about Spi which I had forgotten to enable. I enabled this using the raspi-config util and rebooted the pi.

I then tested the installation by running the sys-info.py example that is mentioned in the installation documentation that comes with the pifacecad board.

Running this example gave a warning saying that the pifacecad hardware could not be found at this point I gave up and decided instead to run my project in python 2.

Of course at first the code wouldnโ€™t run using python 2 and I had to do a bit of digging around to find out what was going wrong.

You may find this useful in the unlikely event that you have a project written in python 3 that you want to run in python 2, it might also be useful if youโ€™re going in the other direction.

One other thing that I briefly stumbled upon was that I believe there is a tool available that attempts to convert python 2 code to python 3 I donโ€™t know anything about it and didnโ€™t bother looking to see if there is a tool to go in the opposite direction which is what I needed. Iโ€™ve included a link to the tool below https://docs.python.org/2/library/2to3.html

Iโ€™ve got the two versions of code loaded into the excellent graphical diff tool meld and Iโ€™ll just briefly cover the things that I had to change.

Link to meld diff tool: https://meldmerge.org/

After some mucking about I got it partially working by installing Piface module for Python 2.7

Had to do the following changes to get the code working in Python 2.7:

    urllib.request.urlopen(url).read()

https://docs.python.org/3/library/urllib.request.html

  • Python 2 uses the urllib2 command. For Python 2 I used the following
    urllib2.urlopen(url).read()

https://docs.python.org/2/library/urllib2.html

  • hostname --all has different output on this version of Debian, now includes mac address which I did not want.

  • Getting the wifi ESSID information. I used iwconfig to get this information. The path to iwconfig command changed in this version of Debian and I now had to give the full path to get it to work.

  • Python 2 and 3 seemed to handle strings differently when converting from an array to a plain string.

  • Python 3 handles input different from python 2

  • If python 2 comes across a non numeric value it quits with an exception

    • so for python 2 I used the command
          raw_input()
    • for python 3 I used the command
          input()

Two article about incorporating future statements in Python 2
https://docs.python.org/3/library/__future__.html

http://simeonvisser.com/posts/how-does-from-future-import-work-in-python.html

Related shows about my PiFaceCAD add on board for the raspberry pi

...



๐Ÿ“Œ HPR3067: Getting my Python3 code working in Python2


๐Ÿ“ˆ 98.9 Punkte

๐Ÿ“Œ BHIS Webcast: Py2k20 โ€“ Transitioning from Python2 to Python3


๐Ÿ“ˆ 40.43 Punkte

๐Ÿ“Œ Py2k20 - Transitioning from Python2 to Python3


๐Ÿ“ˆ 40.43 Punkte

๐Ÿ“Œ DSA-4306 python2.7 - security update


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Fedora 31 To Start Removing Python2-Only Packages


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Fedora 31 To Start Removing Python2-Only Packages


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Python2 removal for focal ...


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Denial of Service in python2 (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Cross-Site Request Forgery in python2.7 (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Cross-Site Request Forgery in python2 (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Fedora is now 99% Python2-free


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Security: Mehrere Probleme in python2-pillow (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Security: Mehrere Probleme in python2-pillow (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Security: Ausfรผhren beliebiger Kommandos in python2.7 (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Security: Ausfรผhren beliebiger Kommandos in python2.7 (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Mehrere Probleme in python2-numpy (SUSE)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Mehrere Probleme in python2-numpy (SUSE)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Removing python2 from the repositories


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Debian has removed the last python2 packages


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Denial of Service in python2.7 (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Denial of Service in python2.7 (Fedora)


๐Ÿ“ˆ 24.22 Punkte

๐Ÿ“Œ Security: Ausfรผhren von Code mit hรถheren Privilegien in python3.9 (Red Hat)


๐Ÿ“ˆ 20.09 Punkte

๐Ÿ“Œ Been getting phished attacked and accounts seem to be getting brute forced ( no luck for them yet)


๐Ÿ“ˆ 16.28 Punkte

๐Ÿ“Œ python3.7.0rc1 now available


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ DSA-4307 python3.5 - security update


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ Ported ARandR to GTK+3 and Python3


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ Python3 - Developing An Nmap Scanner


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ async_bash.py : python3 command to boost bash one-liners


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ Preisgabe von Informationen in python3 (SUSE)


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ Zwei Probleme in python3 (SUSE)


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ Preisgabe von Informationen in python3 (Red Hat)


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ Security: Preisgabe von Informationen in python3 (SUSE)


๐Ÿ“ˆ 16.21 Punkte

๐Ÿ“Œ Security: Mehrere Probleme in python3 (Fedora)


๐Ÿ“ˆ 16.21 Punkte











matomo