Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread NArshad


The user is going to enter the book name as the input of an HTML form on a 
website and I have to check whether the book is present or not in the Excel 
table. openpyxl preferred pandas is also fine anything left. Case sensitivity 
is not required. I tried to find code or tutorial on google search for all this 
but no use that's why..

This time the choice of HTML is right or not??
-- 
https://mail.python.org/mailman/listinfo/python-list


"undefined symbol" in C extension module

2022-01-22 Thread Robert Latest via Python-list
Hi guys,

I've written some CPython extension modules in the past without problems. Now
after moving to a new Archlinux box with Python3.10 installed, I can't build
them any more. Or rather, I can build them but not use them due to "undefined
symbols" during linking. Here's ldd's output when used on the "spam" example
library from the docs:

linux-vdso.so.1 (0x7ffe2454a000)
libc.so.6 => /usr/lib/libc.so.6 (0x7fb6b6eb9000)
/usr/lib64/ld-linux-x86-64.so.2 (0x7fb6b70a4000)
undefined symbol: PyObject_Init (./build/lib.linux-x86_64-3.10/
spam.cpython-310-x86_64-linux-gnu.so)

[and more of the same]

It seems that I need to install some library to make this work, but which one?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Dennis Lee Bieber
On Sat, 22 Jan 2022 02:22:14 -0800 (PST), NArshad 
declaimed the following:

>
>The user is going to enter the book name as the input of an HTML form on a 
>website and I have to check whether the book is present or not in the Excel 
>table. openpyxl preferred pandas is also fine anything left. Case sensitivity 
>is not required. I tried to find code or tutorial on google search for all 
>this but no use that's why..
>
>This time the choice of HTML is right or not??

HTML is the core basis for any web-site presentation -- no HTML, no
web-page.

Interaction with a displayed web-page is via... CGI (individual scripts
that process returned data -- somewhat slow as originally each invocation
requires a full server process startup and shutdown; advances were made to
try to keep a single process running for multiple invocations), AJAX
(Javascript running in the browser making internet requests and modifying
the "document object model" [DOM] in the browser to update the page without
hitting the server for a full update transfer).

Flask, Django, and some others are packages to consolidate what had
been static pages and CGI into a framework that handles an entire "site" --
via templates for look&feel, session management (and cookies) so that
interaction can be tracked to users (HTTP is a fire&forget system -- every
URL sent to the server is treated as a completely separate request).

Above those frameworks are things like Zope -- so-called content
management frameworks.


And again... You will not find anything like you want... NOBODY is
going to write a web application using a spreadsheet as the primary data
storage. A spreadsheet, and custom transformation code, MIGHT be used to
initially populate a database. (M$ SQL Server Integration Services is a
whole system for defining import/transformation/clean-up "functions" for
data sources to data base). A spreadsheet might be available as a
report/extraction format from the database.

Using a web server means you have to be able to handle (near)
simultaneous requests from multiple users and be able to keep those
interactions distinct. That is going to require you to implement some sort
of access control for a spreadsheet, since spreadsheets are single-user
entities (you might get away with shared reading as long as you never need
to update any field in the spreadsheet; as soon as you need to update, you
need to be able to lock records so only one session can update it, and you
need to have a way for other sessions to detect such changes and update
that sessions display for review). On possibility might be to write a
separate process wherein only that process opens the spreadsheet -- all the
web-page stuff will have to generate complete I/O requests to the
spreadsheet process, it will make the changes, and return whatever data is
applicable ("complete" meaning that, if you need to change three fields in
a record, all three commands are provided as ONE request to the spreadsheet
process, and it does all the changes in the request before it goes on to
read the next request). This still falls short of detecting overlapping
changes -- two users want to do something with the same record; they each
read the record, then send commands to change the same field. Which ever
one is received first should complete, and the other needs to be rejected
and resubmitted.



Show us code you've written, and we can assist in debugging it. But you
couldn't afford to have any of us write the application for you! (To cover
insurance, taxes, etc. an independent contractor would probably charge you
$100+ an HOUR -- and the first hours look like they'd be spent getting
detailed requirements from you, discussing design problems [spreadsheet as
data storage], before even getting to any coding. That's real-world
software engineering.)

If you are doing a web application, how are you going to host it? Who
is responsible for managing the web server? Domain name? Firewalls?
Certificates if you need HTTPS rather than plain insecure HTTP. 

I have a Raspberry-Pi with Nginx serving static pages over insecure
HTTP as I've never applied for a certificate -- using a dynamic DNS
service. It is not suited for high-demand as it is behind my ISP router,
and my uplink rate is only a tenth of my downlink rate (which isn't the
fastest thing out there to begin with [Ugh -- Hope it's the weather -- my
downlink is down to 10Mbps, when nominal is closer to 14Mbps]). Someday I
may try creating a Flask application for it, just for learning.


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Chris Angelico
On Sun, 23 Jan 2022 at 07:47, Dennis Lee Bieber  wrote:
> If you are doing a web application, how are you going to host it? Who
> is responsible for managing the web server? Domain name? Firewalls?
> Certificates if you need HTTPS rather than plain insecure HTTP.
>
> I have a Raspberry-Pi with Nginx serving static pages over insecure
> HTTP as I've never applied for a certificate -- using a dynamic DNS
> service. It is not suited for high-demand as it is behind my ISP router,
> and my uplink rate is only a tenth of my downlink rate (which isn't the
> fastest thing out there to begin with [Ugh -- Hope it's the weather -- my
> downlink is down to 10Mbps, when nominal is closer to 14Mbps]). Someday I
> may try creating a Flask application for it, just for learning.
>

Thanks to LetsEncrypt, certificates shouldn't be too hard for any
public-facing server. The Pi can renew and install its own
certificates in a 100% automated process, as long as you can continue
receiving port 80 traffic as well as the port 443 that the live server
would use.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Avi Gross via Python-list

I keep wondering about the questions asked by NArshad here. His message can be 
read below mine, for context.
This is a place focused on using the Python language. The web page being in 
HTML is beyond irrelevant and in particular, web pages generally are in HTML 
even if only as a way to call other functionality.
What I gather is that the web page, irrelevant if in HTML or JAVA or JavaScript 
or a connection with a server running python or anything else, asks the user to 
type in a book name to search for. NOTHING is of any importance here except 
capturing the exact text and sending it, or perhaps a lower case version, back 
to your server that does the search.
Does that make sense? If not, stop reading as nothing else will.
So, back on the server side, you get a single string of text that might look 
like "Great Expectations" and you want to find out if that matches a book title 
exactly or perhaps partially. Again, agreed?
So your program needs to have data available. What if the names of all the 
books were written in a regular text file one line at a time? Yes, they aren't 
but WHAT IF?
You would open the file and perhaps read a line at a time and compare the 
lower-case version of that line to a lower case version of the requested book 
name. An exact match could mean you close the file and return that you found 
it, however that is done. No match means read the next line and repeat. If you 
get to the end of the file without finding it, you failed and close the file 
and return that result.
Of course some might do a bit more than convert to lower case such as removing 
multiple white space in both things being compared, or dropping other parts 
like commas of quotes as in changing "Mine,      didn't I    say!" to "mine 
didnt i say" so more things match as intended. Plenty you can do if you wish. 
Python has plenty of ways to do all that and more.
Now forget the plain text file and consider the following. Read the EXCEL file 
one unit/cell at a time in whatever column and row the data starts. This is 
doable, albeit not necessarily ideal and basically can be the same algorithm 
with a substitution in the part that gets the next line to getting the cell 
below it. Testing for end of file may be different too.
But what I think makes a bit more sense is to setup the server to have a rather 
long-term process that sits there and waits for requests. It starts by reading 
in ALL the data and perhaps modifying it once in ways like I suggest above. In 
python you would now have some data structure such as a list or set or even 
dictionary or some variation from numpy or pandas. It does not matter much. The 
data structure holding all books, or maybe all unique book names, would be 
there and ready and waiting.
Your program now sleeps until woken up and it is given the book name being 
searched for. It now simply needs to apply whatever transformations you want to 
the received name and then do one of many kinds of lookup to see if it is in 
the data structure representing the titles known to the library. Using a set or 
dictionary means no search as it hashes the result and rapidly finds out if it 
has previously been stored. Other methods like lists have choices between a 
brute force linear search if the data remains in the original order or letting 
python do the work by asking if it is "in" the list to more sophisticated 
methods like keeping it sorted and doing a binary search.
I am guessing that for your need, a relatively unsophisticated method may work 
fine and it can be changed if your project scales up to millions of books and 
multiple people searching at the same time.
And note you are now asking about a very limited thing. As others have pointed 
out, there can be much more complex requests such as checking if a copy of the 
book is free, and reserving it so others requesting it see as checked out and 
logging it back in again and more. And obviously more work is needed if you 
want to support more of a google-style search engine that matches books that 
contain only parts of your request.
But note what I am describing can be done by pretty much ANY language as long 
as it can open and read your data storage format. HTML all by itself can 
display a form with a text box and some kind of SUBMIT button and when you 
click on it call a CGI on a server and display what it returns. For the simple 
scenario you mention, you do not need openpyxl. But my guess is you are making 
something with additional functionality based on earlier posts and thus need to 
take care that anything you do can be extended to add functionally, so a raw 
HTML solution may not easily meet other needs. 
I keep hearing you searching for a solution and you may find one but mostly you 
need to design your own solution that meets your needs and use the search more 
for small pieces of the design like "how to efficiently search using a set in 
python" ...
As has been said repeatedly, if you really need the result soon and rea

Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Dennis Lee Bieber
On Sat, 22 Jan 2022 02:22:14 -0800 (PST), NArshad 
declaimed the following:

>
>The user is going to enter the book name as the input of an HTML form on a 
>website and I have to check whether the book is present or not in the Excel 
>table

As written, the user will have to know the exact name of the book, as
it exists in the spreadsheet, and enter exactly that... 

Is it going to be case sensitive?

A Matter of Life and Death
is not the same as
A Matter Of Life And Death

and partial entries won't match either

A Matter of Life

Do you intend to implement fuzzy logic for finding the target given
partial input? If you do, how do you plan to differentiate between two or
more books that match the logic? Do you strip punctuation?

Most systems will, instead, display a list of all books (unless a
filter is specified -- and may require the user to start with a filter just
to avoid a massive scrolling listing), and let the user select from the
list (radio button, check box, item number). A filter would be .


At the level your questions have been -- my biggest suggestion would be
to forget the web form and multi-user problems and write a text-based
console program that can be run from a command line shell. WHEN you get
that working you can consider keeping the logic that interfaces with the
data store, and replace the "presentation" stuff with HTML generation and
web-server integration (any web application will look quite different in
how the code is structured, since a console application has only one flow
-- start the app, make a selection, move to next phase of activity... A web
application has every action as a distinct connection and needs identifying
tokens [cookies] to let the logic know what was done previously)


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


How to test for maildir 'folder' in Python?

2022-01-22 Thread Chris Green
I have a script that walks a quite deep tree of mail messages to find
and archive old messages.  I'm trying to convert it from mbox to
maildir (as I now store my mail in maildir format).

So I need to test whether a point I have reached in the hierarchy is a
maildir mailbox or not.  Using mbox format it's easy because 'folders'
are directories and mailboxes are files.  However with maildir the
'folders' have directories within them so the simple tree walking goes
down a level too far and finds 'folders' which aren't mailboxes called
'cur', 'new' and 'tmp'.

Is there any 'ready made' way in python to tell whether a directory is
a maildir mailbox?  If not I suppose I'll simply have to check if
there are 'cur', 'new' and 'tmp' directories within the directory
which may or may not be a maildir.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Chris Angelico
On Sun, 23 Jan 2022 at 09:15, Dennis Lee Bieber  wrote:
> A web
> application has every action as a distinct connection and needs identifying
> tokens [cookies] to let the logic know what was done previously
>

Usually. Fortunately, we have SOME features that can make life easier,
but in general, yes, web apps need to think in discrete actions with
minimal maintained state.

Absolutely agree with making a console app first. Though I rather
suspect the OP doesn't want to write any code at all.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to test for maildir 'folder' in Python?

2022-01-22 Thread Cameron Simpson
On 22Jan2022 21:26, Chris Green  wrote:
>So I need to test whether a point I have reached in the hierarchy is a
>maildir mailbox or not.  Using mbox format it's easy because 'folders'
>are directories and mailboxes are files.  However with maildir the
>'folders' have directories within them so the simple tree walking goes
>down a level too far and finds 'folders' which aren't mailboxes called
>'cur', 'new' and 'tmp'.
>
>Is there any 'ready made' way in python to tell whether a directory is
>a maildir mailbox?  If not I suppose I'll simply have to check if
>there are 'cur', 'new' and 'tmp' directories within the directory
>which may or may not be a maildir.

I was hoping that the provided mailbox/Maildir class had something, but 
apparently not.

So I suggest fetching my cs.mailutils module from PyPI and using its 
ismaildir(path) function, which does exactly what you describe.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-22 Thread Dennis Lee Bieber
On Sun, 23 Jan 2022 09:17:38 +1100, Chris Angelico 
declaimed the following:


>
>Absolutely agree with making a console app first. Though I rather
>suspect the OP doesn't want to write any code at all.
>

Oh, it's gone beyond suspicion -- considering that, at just 10 lines
per day, over the last 16 days, they should have 160 lines of code (whether
it works or not) that could be presented for evaluation. What is considered
industry standard? 10 lines an hour? Assuming the OP isn't spending time on
requirements analysis and documentation. (My best example is something I
did back around 1990: 18 months consisting of ~600 lines F77, ~2000 lines
of C, and ~2500 lines of DECWindow UIL definition; along with learning both
DECWindow and GKS within it -- so, yes, the overall total is about 2 lines
per day, but I had to develop/document requirements, present them to the
customer, get approval, develop/document the design, present /that/ to the
customer, get approval, before even getting to the code and writing a user
manual for the system... I suspect easily half the time was spent just on
paperwork.)

All we've been shown is four lines, and that wasn't complete enough to
run stand-alone (presuming we ever see a sample of the data to be
processed. There's no complete CONOPS on how this application is to be used
(the most complete we've seen is "if the book is found, decrement some
counter, add user's name to another field" -- and? no report, no one else
is going to look at this information?).

On my part (having no transportation, stuck in a neck brace after
having rolled over my late Jeep, etc.) the alternative to wasting time here
would be to dismantle an AR-10 class rifle and install an adjustable target
(but not top-end match) trigger and, if really ambitious, install an
improved trigger in my Ruger MK-II pistol (I have the parts for both --
just need to set up space and time to do the work).


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "undefined symbol" in C extension module

2022-01-22 Thread Dan Stromberg
Perhaps try:
https://stromberg.dnsalias.org/svn/find-sym/trunk

It tries to find symbols in C libraries.

In this case, I believe you'll find it in -lpythonx.ym


On Sat, Jan 22, 2022 at 12:43 PM Robert Latest via Python-list <
python-list@python.org> wrote:

> Hi guys,
>
> I've written some CPython extension modules in the past without problems.
> Now
> after moving to a new Archlinux box with Python3.10 installed, I can't
> build
> them any more. Or rather, I can build them but not use them due to
> "undefined
> symbols" during linking. Here's ldd's output when used on the "spam"
> example
> library from the docs:
>
> linux-vdso.so.1 (0x7ffe2454a000)
> libc.so.6 => /usr/lib/libc.so.6 (0x7fb6b6eb9000)
> /usr/lib64/ld-linux-x86-64.so.2 (0x7fb6b70a4000)
> undefined symbol: PyObject_Init (./build/lib.linux-x86_64-3.10/
> spam.cpython-310-x86_64-linux-gnu.so)
>
> [and more of the same]
>
> It seems that I need to install some library to make this work, but which
> one?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list