Re: wsgi on RedHat 9
Tonu Mikk via Roundup-users <[email protected]> Thu, 8 Feb 2024 09:40:33 -0600
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <CABDFm8iZh3yPtqOb1zpLxKvy4LpJ8c5hCLtzOZWgCRz5y512Pw@mail.gmail.com> |
--===============9222618097585373919== Content-Type: multipart/alternative; boundary="000000000000f332bc0610e0a374" --000000000000f332bc0610e0a374 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Something else to note. When I set the SELinux to "enforcing" the tracker fails. The error log indicates that the tracker is trying to retrieve files from '/home/tmikk/.local/lib/python3.9/site-packages/roundup directory and not finding them. I believe I can modify the SELinux for roundup's use and still set it to "enforcing". On Thu, Feb 8, 2024 at 9:25=E2=80=AFAM Tonu Mikk <[email protected]> wrote: > I got it to work! > > I found the Apache modified wsgi handler in Roundup documentation. I trie= d > to modify it by using the roundup installation in my home directory > sys.path.insert(0, > '(home/tmikk/.local/lib/python3.9/site-packages/roundup') but that didn't > work. > > I then ran > sudo pip install roundup > > I got this message: > Requirement already satisfied: roundup in > /usr/local/lib/python3.9/site-packages (2.3.0) > WARNING: Running pip as the 'root' user can result in broken permissions > and conflicting behaviour with the system package manager. It is > recommended to use a virtual environment instead: > https://pip.pypa.io/warnings/venv > > I must have tried this command already as Roundup was already installed > using this method. I then used the Roundup's path > (/usr/local/lib/python3.9/site-packages) in the wsgi handler and also > changed the home directory path which made it work. My wsgi handler now > looks like this. > > import sys, os > sys.stdout =3D sys.stderr > > enabled =3D True > > if enabled: > # Add the directory with the roundup installation > # subdirectory to the python path. > sys.path.insert(0, ' /usr/local/lib/python3.9/site-packages ') > > # obtain the WSGI request dispatcher > from roundup.cgi.wsgi_handler import RequestDispatcher > > tracker_home =3D '/opt/trackers/classic' > application =3D RequestDispatcher(tracker_home) > else: > def application(environ, start_response): > status =3D '503 Service Unavailable' > output =3D 'service is down for maintenance' > response_headers =3D [('Content-type', 'text/plain'), > ('Content-Length', str(len(output)))] > start_response(status, response_headers) > return [output] > > We have a couple of things we would like to track and I thought that > creating a generic url naming (/piano) might be a good way to go. We may > have more than one tracker and I can add another musical instrument /guit= ar > for example. It is a bit experimental right now and I don't know if it wi= ll > come to fruition. > > Thanks for all the help! > > On Wed, Feb 7, 2024 at 3:47=E2=80=AFPM Tonu Mikk <[email protected]> wrote: > >> Thanks for these additional ideas! I am now seeing where the problem is. >> >> The command >> python3 -c 'import sys;print(sys.version); print(sys.prefix);' shows the >> same information as the test_wsgi output: >> 3.9.18 (main, Sep 7 2023, 00:00:00) >> [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] >> /usr >> >> When running >> python3 -c 'import roundup; print(roundup)' >> I get: >> <module 'roundup' from >> '/home/tmikk/.local/lib/python3.9/site-packages/roundup/__init__.py'> >> I had started the roundup install by first creating a python virtual >> environment in my home directory and then installing roundup there using >> pip. Looks like this is where my problem is. I don't even see roundup in >> /usr/lib64/python3.9/site-packages. >> >> I hadn't set the PYTHONPATH environment variable. >> >> The command >> python3 -c 'import sys; print("\n".join(sys.path))' >> >> gives me this output. >> /usr/lib64/python39.zip >> /usr/lib64/python3.9 >> /usr/lib64/python3.9/lib-dynload >> /home/tmikk/.local/lib/python3.9/site-packages >> /usr/lib64/python3.9/site-packages >> /usr/lib/python3.9/site-packages >> >> >> On Wed, Feb 7, 2024 at 3:30=E2=80=AFPM John P. Rouillard <[email protected].= edu> >> wrote: >> >>> Hi Tonu: >>> >>> In message >>> <CABDFm8jpdukd-rbVbpcKxnFHPEgCuZK7NPTfveSKLZvCMVEbjA@mail.gmail.com> , >>> Tonu Mikk writes: >>> >The command >>> > python3 -c 'import roundup' >>> >runs without an error. >>> >>> Stupid idea does: >>> >>> python3 -c 'import sys;print(sys.version); print(sys.prefix);' >>> >>> print the same as your test_wsgi? I expect it will. >>> >>> Also can you run: >>> >>> python3 -c 'import roundup; print(roundup)' >>> >>> to see where the library is? It's possible you have it installed in >>> some odd place that the wsgi python invocation isn't looking. Do you >>> have PYTHONPATH set in your environment per chance? >>> >>> Also running: >>> >>> python3 -c 'import sys; print("\n".join(sys.path))' >>> >>> or printing sys.path from test_wsgi may give us some more info. >>> >>> If that's the case, you can add: >>> >>> # Add the directory with the roundup installation >>> # subdirectory to the python path. >>> sys.path.insert(0, '/home/roundup/install/lib/python') >>> >>> to the wsgi script as mentioned in a couple of places on the >>> installation page (search for sys.path). >>> >>> >I changed the test_wsgi.py to contain this: >>> >import sys >>> > >>> >def application(environ, start_response): >>> > status =3D '200 OK' >>> > >>> > output =3D u'' >>> > output +=3D u'sys.version =3D %s\n' % repr(sys.version) >>> > output +=3D u'sys.prefix =3D %s\n' % repr(sys.prefix) >>> > >>> > response_headers =3D [('Content-type', 'text/plain'), >>> > ('Content-Length', str(len(output)))] >>> > start_response(status, response_headers) >>> > >>> > return [output.encode('UTF-8')] >>> > >>> >Now the output in the browser shows: >>> >sys.version =3D '3.9.18 (main, Sep 7 2023, 00:00:00) \n[GCC 11.4.1 >>> 20230605 >>> >(Red Hat 11.4.1-2)]' >>> >sys.prefix =3D '/usr' >>> > >>> >I will try to use the virtual environment with mod_wsgi. Thanks for >>> >pointing this out! >>> >>> That's the more resiliant way to do it, but I would like to get to the >>> bottom of the issue you had with a os native installation. >>> >>> Have a great day. >>> -- >>> -- rouilj >>> John Rouillard >>> >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D >>> My employers don't acknowledge my existence much less my opinions. >>> >> >> >> -- >> Tonu Mikk >> Developer | Disability Resource Center | disability.umn.edu >> University of Minnesota | umn.edu >> [email protected] >> Pronouns: He/Him >> > > > -- > Tonu Mikk > Developer | Disability Resource Center | disability.umn.edu > University of Minnesota | umn.edu > [email protected] > Pronouns: He/Him > --=20 Tonu Mikk Developer | Disability Resource Center | disability.umn.edu University of Minnesota | umn.edu [email protected] Pronouns: He/Him --000000000000f332bc0610e0a374 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Something else to note. When I set the SELinux to "en= forcing" the tracker fails. The error log indicates that the tracker i= s trying to retrieve files from '/home/tmikk/.local/lib/python3.9/site-= packages/roundup directory and not finding them.=C2=A0<div><br></div><div>I= believe I can modify the SELinux for roundup's use and still set it to= "enforcing".=C2=A0</div></div><br><div class=3D"gmail_quote"><di= v dir=3D"ltr" class=3D"gmail_attr">On Thu, Feb 8, 2024 at 9:25=E2=80=AFAM T= onu Mikk <<a href=3D"mailto:[email protected]">[email protected]</a>> wrote:<= br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e= x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"= >I got it to work!<div><br></div><div>I found the Apache modified wsgi hand= ler in Roundup documentation. I tried to modify it by using the roundup ins= tallation in my home directory</div><div>=C2=A0=C2=A0sys.path.insert(0, = 9;(home/tmikk/.local/lib/python3.9/site-packages/roundup') but that did= n't work.</div><div><br></div><div>I then ran=C2=A0</div><div>sudo pip = install roundup</div><div><br></div><div>I got this message:</div><div>Requ= irement already satisfied: roundup in /usr/local/lib/python3.9/site-package= s (2.3.0)<br>WARNING: Running pip as the 'root' user can result in = broken permissions and conflicting behaviour with the system package manage= r. It is recommended to use a virtual environment instead: <a href=3D"https= ://pip.pypa.io/warnings/venv" target=3D"_blank">https://pip.pypa.io/warning= s/venv</a><br></div><div><br></div><div>I must have tried this command alre= ady as Roundup was already installed using this method. I then used the Rou= ndup's path (/usr/local/lib/python3.9/site-packages) in the wsgi handle= r and also changed the home directory path which made it work. My wsgi hand= ler now looks like this.</div><div><div><br></div><div>import sys, os<br>sy= s.stdout =3D sys.stderr<br><br>enabled =3D True<br><br>if enabled:<br>=C2= =A0 =C2=A0 # Add the directory with the roundup installation<br>=C2=A0 =C2= =A0 # subdirectory to the python path.<br>=C2=A0 =C2=A0 sys.path.insert(0, = ' /usr/local/lib/python3.9/site-packages ')<br><br>=C2=A0 =C2=A0 # obtain= the WSGI request dispatcher<br>=C2=A0 =C2=A0 from roundup.cgi.wsgi_handler= import RequestDispatcher<br><br>=C2=A0 =C2=A0 tracker_home =3D '/opt/t= rackers/classic'<br>=C2=A0 =C2=A0 application =3D RequestDispatcher(tra= cker_home)<br>else:<br>=C2=A0 =C2=A0 def application(environ, start_respons= e):<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 status =3D '503 Service Unavailable&= #39;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 output =3D 'service is down for mai= ntenance'<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 response_headers =3D [('Co= ntent-type', 'text/plain'),<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ('Co= ntent-Length', str(len(output)))]<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 start_= response(status, response_headers)<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return [o= utput]<br></div></div><div><br></div><div>We have a couple of things we wou= ld like to track and I thought that creating a generic url naming (/piano) = might be a good way to go. We may have more than one tracker and I can add = another musical instrument /guitar for example. It is a bit experimental ri= ght now and I don't know if it will come to fruition.</div><div><br></d= iv><div>Thanks for all the help!</div></div><br><div class=3D"gmail_quote">= <div dir=3D"ltr" class=3D"gmail_attr">On Wed, Feb 7, 2024 at 3:47=E2=80=AFP= M Tonu Mikk <<a href=3D"mailto:[email protected]" target=3D"_blank">tmikk@um= n.edu</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"ma= rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:= 1ex"><div dir=3D"ltr">Thanks for these additional ideas! I am now seeing wh= ere the problem is.=C2=A0<div><br></div><div>The command=C2=A0</div><div>py= thon3 -c 'import sys;print(sys.version); print(sys.prefix);' shows = the same information as the test_wsgi output:<br></div><div>3.9.18 (main, S= ep =C2=A07 2023, 00:00:00)<br>[GCC 11.4.1 20230605 (Red Hat 11.4.1-2)]<br>/= usr<br></div><div><br></div><div>When running=C2=A0</div><div>=C2=A0 =C2=A0= python3 -c 'import roundup; print(roundup)'<br></div><div>I get:</d= iv><div><module 'roundup' from '/home/tmikk/.local/lib/pytho= n3.9/site-packages/roundup/__init__.py'><br></div><div>I had started= the roundup install by first creating a python virtual environment in my h= ome directory and then installing roundup there using pip. Looks like this = is where my problem is.=C2=A0I don't even see roundup in /usr/lib64/pyt= hon3.9/site-packages.=C2=A0</div><div><br></div><div>I hadn't set the P= YTHONPATH environment variable.=C2=A0</div><div><br></div><div>The command= =C2=A0</div><div>python3 -c 'import sys; print("\n".join(sys.= path))'<br></div><div><br></div><div>gives me this output.</div><div>/u= sr/lib64/python39.zip<br>/usr/lib64/python3.9<br>/usr/lib64/python3.9/lib-d= ynload<br>/home/tmikk/.local/lib/python3.9/site-packages<br>/usr/lib64/pyth= on3.9/site-packages<br>/usr/lib/python3.9/site-packages<br></div><div><br><= /div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_a= ttr">On Wed, Feb 7, 2024 at 3:30=E2=80=AFPM John P. Rouillard <<a href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>> w= rote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p= x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Tonu:<b= r> <br> In message<br> <<a href=3D"mailto:CABDFm8jpdukd-rbVbpcKxnFHPEgCuZK7NPTfveSKLZvCMVEbjA@m= ail.gmail.com" target=3D"_blank">CABDFm8jpdukd-rbVbpcKxnFHPEgCuZK7NPTfveSKL= [email protected]</a>> ,<br> Tonu Mikk writes:<br> >The command<br> >=C2=A0 =C2=A0python3 -c 'import roundup'<br> >runs without an error.<br> <br> Stupid idea does:<br> <br> =C2=A0 =C2=A0python3 -c 'import sys;print(sys.version); print(sys.prefi= x);'<br> <br> print the same as your test_wsgi? I expect it will.<br> <br> Also can you run:<br> <br> =C2=A0 =C2=A0python3 -c 'import roundup; print(roundup)'<br> <br> to see where the library is? It's possible you have it installed in<br> some odd place that the wsgi python invocation isn't looking. Do you<br= > have PYTHONPATH set in your environment per chance?<br> <br> Also running:<br> <br> =C2=A0 python3 -c 'import sys; print("\n".join(sys.path))'= ;<br> <br> or printing sys.path from test_wsgi may give us some more info.<br> <br> If that's the case, you can add:<br> <br> =C2=A0 # Add the directory with the roundup installation<br> =C2=A0 # subdirectory to the python path.<br> =C2=A0 sys.path.insert(0, '/home/roundup/install/lib/python')<br> <br> to the wsgi script as mentioned in a couple of places on the<br> installation page (search for sys.path).<br> <br> >I changed the test_wsgi.py to contain this:<br> >import sys<br> ><br> >def application(environ, start_response):<br> >=C2=A0 =C2=A0 status =3D '200 OK'<br> ><br> >=C2=A0 =C2=A0 output =3D u''<br> >=C2=A0 =C2=A0 output +=3D u'sys.version =3D %s\n' % repr(sys.ve= rsion)<br> >=C2=A0 =C2=A0 output +=3D u'sys.prefix =3D %s\n' % repr(sys.pre= fix)<br> ><br> >=C2=A0 =C2=A0 response_headers =3D [('Content-type', 'text/= plain'),<br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 ('Content-Length', str(len(output)))]<br> >=C2=A0 =C2=A0 start_response(status, response_headers)<br> ><br> >=C2=A0 =C2=A0 return [output.encode('UTF-8')]<br> ><br> >Now the output in the browser shows:<br> >sys.version =3D '3.9.18 (main, Sep=C2=A0 7 2023, 00:00:00) \n[GCC 1= 1.4.1 20230605<br> >(Red Hat 11.4.1-2)]'<br> >sys.prefix =3D '/usr'<br> ><br> >I will try to use the virtual environment with mod_wsgi. Thanks for<br> >pointing this out!<br> <br> That's the more resiliant way to do it, but I would like to get to the<= br> bottom of the issue you had with a os native installation.<br> <br> Have a great day.<br> --<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 -- rouilj<br> John Rouillard<br> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= <br> My employers don't acknowledge my existence much less my opinions.<br> </blockquote></div><br clear=3D"all"><div><br></div><span class=3D"gmail_si= gnature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signature"><d= iv dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><span sty= le=3D"border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"= ><font color=3D"#666666"><div>Tonu Mikk</div><div>Developer | Disability Re= source Center | <a href=3D"https://disability.umn.edu" target=3D"_blank">di= sability.umn.edu</a></div><div>University of Minnesota | <a href=3D"http://= umn.edu" target=3D"_blank">umn.edu</a>=C2=A0</div><div><a href=3D"mailto:tm= [email protected]" target=3D"_blank">[email protected]</a>=C2=A0</div><div>Pronouns: = He/Him</div></font></span></div></div></div></div></div> </blockquote></div><br clear=3D"all"><div><br></div><span class=3D"gmail_si= gnature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signature"><d= iv dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><span sty= le=3D"border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"= ><font color=3D"#666666"><div>Tonu Mikk</div><div>Developer | Disability Re= source Center | <a href=3D"https://disability.umn.edu" target=3D"_blank">di= sability.umn.edu</a></div><div>University of Minnesota | <a href=3D"http://= umn.edu" target=3D"_blank">umn.edu</a>=C2=A0</div><div><a href=3D"mailto:tm= [email protected]" target=3D"_blank">[email protected]</a>=C2=A0</div><div>Pronouns: = He/Him</div></font></span></div></div></div></div></div> </blockquote></div><br clear=3D"all"><div><br></div><span class=3D"gmail_si= gnature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signature"><d= iv dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><span sty= le=3D"border-collapse:collapse;font-family:arial,sans-serif;font-size:13px"= ><font color=3D"#666666"><div>Tonu Mikk</div><div>Developer | Disability Re= source Center | <a href=3D"https://disability.umn.edu" target=3D"_blank">di= sability.umn.edu</a></div><div>University of Minnesota | <a href=3D"http://= umn.edu" target=3D"_blank">umn.edu</a>=C2=A0</div><div><a href=3D"mailto:tm= [email protected]" target=3D"_blank">[email protected]</a>=C2=A0</div><div>Pronouns: = He/Him</div></font></span></div></div></div></div></div> --000000000000f332bc0610e0a374-- --===============9222618097585373919== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============9222618097585373919== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Roundup-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/roundup-users --===============9222618097585373919==--