Commit Graph

17 Commits

Author SHA1 Message Date
Sebastian Lohff f668fc3fe6 Release 0.5.4 2023-01-23 23:40:14 +01:00
Sebastian Lohff f23dfd2a51 Ignore python3.11 cgi deprecation warning
The cgi module is marked as deprecated and will be removed in
python3.13. servefile uses the module for its FieldStorage class used in
the upload functionality. For now I will just ignore this, so servefile
doesn't print out the warning each time it is run, but soon this will
require either a rewrite of FieldStorage or an external library.

With this commit we also now officially support python3.10 and
python3.11.
2023-01-23 23:40:14 +01:00
Sebastian Lohff b1145af6bb Code formatting
* removed weird linebreaks for for-loop
 * no () for del statement
2023-01-23 23:40:14 +01:00
MasterofJOKers 0b010d5c10 Upload to uploaddir instead of /tmp
When uploading larger files, cgi.FieldStorage decides to store the files
in an unnamed temporary file in /tmp while parsing the form-data. This
is counter-intuitive and might not work, if the partition hosting /tmp/
is too small. Therefore, we overwrite FieldStorage's make_file() method
to use the targetDir as upload path.

While we're at it, we also use NamedTemporaryFile instead of
TemporaryFile, because that lets us use os.link() to create a "copy" of
the file-data without writing it to disk a second time. This does not
work for small data, because small data is kept in an BytesIO object and
thus never written to file automatically. For this case, we keep the old
code, that's writing down files manually.

We have to inline-define CustomFieldStorage, because FieldStorage will
instantiate a new FieldStorage instance for parsing the parts of a
multipart/form-data body and thus we cannot pass targetDir via
__init__() argument.

Signed-off-by: MasterofJOKers <joker@someserver.de>
2022-01-18 22:52:44 +01:00
Sebastian Lohff 5dcf364e0f Code formatting: Whitespace around operators 2022-01-18 21:33:15 +01:00
Sebastian Lohff aa54e8536a Further codeformatting
* break up some extra long lines
 * add a bit of noqa for warnings I don't want to have
 * rework formatting for ip addr / ifconfig part
2022-01-18 21:33:15 +01:00
Sebastian Lohff 96e9e76ff4 Code reformatting
* replace tabs with spaces
 * replace some of the != None with is not None etc.
 * more whitespace fixes
 * remove all the newline \
2022-01-18 21:33:15 +01:00
Sebastian Lohff c7af20388d Release v0.5.3 2021-11-18 00:32:41 +01:00
Sebastian Lohff cd28811fcf Release v0.5.2 2021-09-08 00:23:11 +02:00
Paweł Chojnacki 6537c054e5 Fix PUT uploads
PUT uploads were broken on python 3.9 and were lacking tests.
2021-07-14 00:11:16 +02:00
Sebastian Lohff 65fcac5c49 Fix encoding handling for file listing with py2
File listings with -l that contained files with umlauts or other special
chars could break the directory listing. Hopefully one of the last
python2 fixes before I drop support for this.
2021-06-08 23:46:30 +02:00
Sebastian Lohff 9fa4ed0026 Quote filenames in Location header on redirect
When we redirect the user to the "correct" file name this name should
end up quoted in the header, else we would end up in an infinite
redirect loop.
2021-06-08 23:46:30 +02:00
Sebastian Lohff e31c8fb016 Fix broken pyopenssl and debian references
servefile used to hint to install pyssl when ssl support was missing.
This is utterly wrong, because the package is named pyopenssl - as
stated in setup.py. Installing pyssl will not only not lead to ssl
support, but also install a random package that we do not want.

Also, since python2 has genereally been deprecated (though it is still
support by servefile for now) we hint for the python3 package of
pyopenssl instead of the python2 version. I thought about building a
version detection and print the right package, depending if the user is
using python2 or 3, but I deemed it not being worth it.

Fixes #7 (GitHub)
2021-02-14 21:07:25 +01:00
Sebastian Lohff 058de2f39c Fix exception on transmission abort with python3
With python3 sys.exc_value does no longer exist, but we can replace it
with sys.exc_info().
2021-01-27 01:31:15 +01:00
Sebastian Lohff 11a7d8bd13 Release v0.5.1 2020-09-30 01:44:57 +02:00
Sebastian Lohff f2594c2adf Release v0.5.0 2020-09-30 01:28:48 +02:00
Sebastian Lohff 19c1b000a4 Make servefile a python package
servefile is now a valid python package. The single servefile.py can
still be used as a script by just putting it into PATH and making it
executable. Additionally when installed via pip a wrapper script is
created, calling the module's main(). python -m servefile works as well.
2020-09-07 00:26:20 +02:00