<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Frank Seitz - Developer Logbuch - Python</title>
    <link>http://fseitz.de/blog/</link>
    <description>Notizen aus der Welt der Programmierung und Administration</description>
    <dc:language>de</dc:language>
    <generator>Serendipity 1.5.1 - http://www.s9y.org/</generator>
    <pubDate>Tue, 17 Aug 2021 18:49:11 GMT</pubDate>

    <image>
        <url>http://fseitz.de/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Frank Seitz - Developer Logbuch - Python - Notizen aus der Welt der Programmierung und Administration</title>
        <link>http://fseitz.de/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>PyPerler: Perl-Klassen unter Python nutzen</title>
    <link>http://fseitz.de/blog/index.php?/archives/162-PyPerler-Perl-Klassen-unter-Python-nutzen.html</link>
            <category>Perl</category>
            <category>Python</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/162-PyPerler-Perl-Klassen-unter-Python-nutzen.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=162</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=162</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;https://github.com/tkluck/pyperler&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/python-perl-370x65.png&quot; width=&quot;268&quot; height=&quot;47&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://github.com/tkluck/pyperler&quot;&gt;PyPerler&lt;/a&gt; ist ein Python-Package mit dem es möglich ist, Perl-Code
  unter Python zu nutzen. Es wird vom Autor nach eigener Aussage zur
  Zeit nicht gepflegt, funktioniert aber recht gut (Einschränkungen
  siehe unten). Es lassen sich damit sogar komplexe Perl-Klassen unter
  Python verwenden, wie z.B. Datenbank-Operationen über einen
  O/R-Mapper. Ich experimentiere zur Zeit damit unter Debian 10 mit
  Python 3.7.3 und Perl 5.28.1.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Installation&lt;/h1&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Wir setzen zunächt eine virtuelle Umgebung auf, in die wir PyPerler
  installieren:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ virtualenv venv&amp;#10;$ . venv/bin/activate&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Wir holen den Sourcecode von GitHub:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ git clone https://github.com/tkluck/pyperler.git&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Wir kompilieren den Code und installieren PyPerler in die virtuelle Umgebung:
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ cd pyperler&amp;#10;$ make&amp;#10;$ make install&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Nun können wir Perl-Code von Python aus nutzen. Ein Beispiel
  findet sich im &lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://github.com/tkluck/pyperler#pyperler&quot;&gt;README&lt;/a&gt;.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Probleme&lt;/h1&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Operatoren sind nicht vollständig überladen&lt;/h2&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Die Operator-Methoden &lt;tt class=&quot;sdoc-seg-c&quot;&gt;__radd__()&lt;/tt&gt;, &lt;tt class=&quot;sdoc-seg-c&quot;&gt;__rmul__()&lt;/tt&gt; usw. fehlen in Klasse
  &lt;tt class=&quot;sdoc-seg-c&quot;&gt;ScalarValue&lt;/tt&gt;, so dass unter o.g. Python-Version ein Perl-Skalar ohne
  explizite Typwandlung zwar linksseitig mit einem Python-Objekt
  verknüpft werden kann, aber nicht rechtsseitig. Diese Definitionen
  lassen sich relativ einfach nachtragen. Als Richtschnur kann
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ make check&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  genutzt werden, das die Defizite aufzeigt.
&lt;/p&gt;

&lt;h2 class=&quot;sdoc-sec-h2&quot;&gt;Die Extension ist nicht thread-save&lt;/h2&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Pyperler ist offenbar nicht thread-save. Eine Flask-Anwendung muss mit
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ flask run --without-threads&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  gestartet werden, sonst stürzt sie mit einem Segmentation Fault beim
  ersten Zugriff auf ein Perl-Objekt ab. Dies hat möglicherweise mit
  einem Fehler bei der Nutzung von Cythons &lt;i class=&quot;sdoc-seg-i&quot;&gt;Global Interpreter Lock&lt;/i&gt; (GIL)
  zu tun.
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Links&lt;/h1&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;&lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://github.com/tkluck/pyperler&quot;&gt;PyPerler&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Mon, 14 Dec 2020 17:20:00 +0100</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/162-guid.html</guid>
    
</item>
<item>
    <title>Selenium+Python+Firefox: Unable to find a matching set of capabilities</title>
    <link>http://fseitz.de/blog/index.php?/archives/160-Selenium+Python+Firefox-Unable-to-find-a-matching-set-of-capabilities.html</link>
            <category>Python</category>
            <category>Selenium</category>
    
    <comments>http://fseitz.de/blog/index.php?/archives/160-Selenium+Python+Firefox-Unable-to-find-a-matching-set-of-capabilities.html#comments</comments>
    <wfw:comment>http://fseitz.de/blog/wfwcomment.php?cid=160</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://fseitz.de/blog/rss.php?version=2.0&amp;type=comments&amp;cid=160</wfw:commentRss>
    

    <author>nospam@example.com (Frank Seitz)</author>
    <content:encoded>
    &lt;p class=&quot;sdoc-fig-p&quot;&gt;
  &lt;a href=&quot;https://selenium-python.readthedocs.io/&quot;&gt;&lt;img class=&quot;sdoc-fig-img&quot; src=&quot;http://fseitz.de/blog/uploads/selenium-python-1740x363.png&quot; width=&quot;192&quot; height=&quot;40&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Das Python-Programm
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: python; toolbar: false; pad-line-numbers: 1&quot;&gt;#!/usr/bin/env python3&amp;#10;&amp;#10;from selenium import webdriver&amp;#10;driver = webdriver.Firefox()&amp;#10;&amp;#10;# eof&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  führt unter Debian zu dem Fehler
&lt;/p&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;Traceback (most recent call last):&amp;#10;  File &quot;./test.py&quot;, line 5, in &amp;lt;module&amp;gt;&amp;#10;    driver = webdriver.Firefox()&amp;#10;  File &quot;.../venv/lib/python3.7/site-packages/selenium/webdriver/firefox/&amp;#10;    webdriver.py&quot;, line 174, in __init__ keep_alive=True)&amp;#10;  File &quot;.../venv/lib/python3.7/site-packages/selenium/webdriver/remote/&amp;#10;    webdriver.py&quot;, line 157, in __init__ self.start_session(capabilities,&amp;#10;    browser_profile)&amp;#10;  File &quot;.../venv/lib/python3.7/site-packages/selenium/webdriver/remote/&amp;#10;    webdriver.py&quot;, line 252, in start_session response = self.execute(&amp;#10;    Command.NEW_SESSION, parameters)&amp;#10;  File &quot;.../venv/lib/python3.7/site-packages/selenium/webdriver/remote/&amp;#10;    webdriver.py&quot;, line 321, in execute self.error_handler.check_response(&amp;#10;    response)&amp;#10;  File &quot;.../venv/lib/python3.7/site-packages/selenium/webdriver/remote/&amp;#10;    errorhandler.py&quot;, line 242, in check_response raise exception_class(&amp;#10;    message, screen, stacktrace)&amp;#10;selenium.common.exceptions.SessionNotCreatedException: Message: Unable&amp;#10;    to find a matching set of capabilities&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  Grund hierfür ist, dass unter Debian &lt;tt class=&quot;sdoc-seg-c&quot;&gt;firefox&lt;/tt&gt; ein Shellskript
  ist, das das &quot;richtige&quot; Firefox-Executable &lt;tt class=&quot;sdoc-seg-c&quot;&gt;firefox-esr&lt;/tt&gt; indirekt aufruft.
  Damit kann der WebDriver von Firefox (&lt;tt class=&quot;sdoc-seg-c&quot;&gt;geckodriver&lt;/tt&gt;) nicht umgehen.
  Die Lösung ist, bei der Instantiierung des Firefox-Drivers den Pfad zum
  Firefox-Executable explizit anzugeben:
&lt;/p&gt;
&lt;div class=&quot;sdoc-highlight-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre brush: python; toolbar: false; pad-line-numbers: 1&quot;&gt;#!/usr/bin/env python3&amp;#10;&amp;#10;from selenium import webdriver&amp;#10;driver = webdriver.Firefox(firefox_binary=&quot;/usr/bin/firefox-esr&quot;)&amp;#10;&amp;#10;# eof&lt;/pre&gt;
&lt;/div&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Installation von Python-Bindings für Selenium und Firefox-Treiber in Virtualenv-Umgebung&lt;/h1&gt;
&lt;div class=&quot;sdoc-code-div&quot;&gt;
  &lt;pre class=&quot;sdoc-code-pre&quot;&gt;$ virtualenv venv&amp;#10;$ . venv/bin/activate&amp;#10;$ pip install selenium&amp;#10;$ curl -L https://github.com/mozilla/geckodriver/releases/download/v0.27.0/&amp;#10;  geckodriver-v0.27.0-linux64.tar.gz | (cd venv/bin; tar xvzf -)&lt;/pre&gt;
&lt;/div&gt;
&lt;p class=&quot;sdoc-para-p&quot;&gt;
  (mit dem geckodriver, der zum Zeitpunkt dieses Artikels aktuell war)
&lt;/p&gt;

&lt;h1 class=&quot;sdoc-sec-h1&quot;&gt;Links&lt;/h1&gt;
&lt;ul class=&quot;sdoc-list-ul&quot;&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;&lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://pypi.org/project/selenium/&quot;&gt;Selenium für Python&lt;/a&gt;&lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;&lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://selenium-python.readthedocs.io/&quot;&gt;Selenium für Python - Inoffizielle Dokumentation&lt;/a&gt;&lt;/li&gt;
  &lt;li class=&quot;sdoc-list-li-point&quot; style=&quot;list-style-type:disc&quot;&gt;&lt;a class=&quot;sdoc-seg-u&quot; href=&quot;https://github.com/mozilla/geckodriver/releases&quot;&gt;WebDriver Firefox&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
 
    </content:encoded>

    <pubDate>Wed, 12 Aug 2020 20:03:00 +0200</pubDate>
    <guid isPermaLink="false">http://fseitz.de/blog/index.php?/archives/160-guid.html</guid>
    
</item>

</channel>
</rss>