You are not logged in.
I've added the pid to the information that it prints out at startup. You can use that to kill it. After a quick search it seems that changing the name of Python processes is difficult and requires non-portable code, so I don't think I'll bother trying to implement that.
I've also added a "--filelist" option which you can use to specify a list of files, one per line. Quickserve will detect changes to that file while running, so you can modify it to add or remove files without restarting quickserve. Note that if you use that option, it will ignore all paths passed to it on the command line.
For reference, it is possible to serve a directory with quickserve and then copy files or create symlinks in that directory once quickserve is running.
I won't add code to check if files exist and exit if they don't because there may be times when it is useful to specify a path that hasn't been created yet, such as for an ongoing download or the output of a cronjob. The user shouldn't specify non-existent paths on the command line anyway.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Is it too much to print pid info on the web page? Unless I write down the pid, I'll not remember it 5 minutes from seeing it.
I like the filelist option...thank you.
Offline
I considered that at first but didn't do it because I didn't want to add the extra code. I see how it can be useful though so I've reconsidered and added an "--infopage" option. If you pass it a path, that path will display info about the server, including the pid.
The Firefox bug may make some paths inaccessible though, so you have to keep that in mind when using this option with Firefox.
More info about the Firefox bug:
http://xyne.archlinux.ca/info/quickserve
http://bbs.archlinux.org/viewtopic.php? … 67#p692067
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
"--infopage" work for me...thanks.
filelist is broken though. I got these error when running "quickserve -f .quickservefiles"
Traceback (most recent call last):
File "/usr/bin/quickserve", line 553, in <module>
print "error: failed to stat %s: %s" % (fpath,strerror)
NameError: name 'fpath' is not defined
Did you know quickserve with authentication does not work on google-chrome? I'm using 4.0.302.2 dev version and the authentication window never popup.
Offline
Nice script, unfortunately does not work with python 2.4 (no hashlib, no rpartition...) and I would need it to be that portable to be useful to me. So far the simpler alternative $ python -m SimpleHTTPServer 8080 was good enough.
You need to install an RTFM interface.
Offline
@tri1976
I've corrected the "fpath" error. You should see another error now, but you'll understand why that's intentional.
@anrxc
I do not have python 2.4 installed so I can't test backwards compatibility. If all of the changes were trivial (e.g. replacing rpartition) then I would consider implementing them, but I suspect that adding code to support modules which have been deprecated would not be completely trivial (e.g. md5 instead of hashlib).
To be honest, I might have been more motivated if you had phrased your post differently. Indirectly requesting support for deprecated code that would only benefit yourself and very few other people while simultaneously stating that another "simpler" solution is "good enough" just isn't motivational at all.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
It works....everything appears to be functional. I don't see any other error...hmmm, am I missing something?
Offline
@cool
http://xyne.archlinux.ca/img/quickserve_02.pngJust click on [More] to get more upload fields.
Haha...didn't notice the "more" button. My bad
Thanks for replying
Offline
@tri1976
The fpath error was inside a block that is only executed if the filelist cannot be statted. I expected it to throw a "cannot stat file" error but apparently you passed it the correct path after the fix.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
ah...yes, I did get this message when the file doesn't exist....but I thought that was just normal behavior. Do you have any idea why authentication doesn't work with google chrome? Maybe it's not the same authentication method, but I use transmission for torrent download and its authentication popup fine.
Offline
Xyne, I could have phrased it better. The simplehttp server was good enough but I used your script and it was better for me. Maybe it would not benefit many people, infact only one... now you know your coding style does not work so far back, and if your script grows beyond Arch Linux there will be others to mention or adapt it.
You need to install an RTFM interface.
Offline
@tri1976
Test the latest version and let me know if authentication works with Chrome.
@anrxc
Ok. Sorry if I read your post the wrong way. It can be difficult to get the right tone of a forum post.
If you could provide a list of changes that would make it compatible with 2.4, I will consider implementing them, but until I've seen the list, I will not commit myself to it.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
It works...once again great tool...thank you.
I wrote a small bash script around quickserve to let me quickly share files in a graphical file manager, do you mind if I post it here for those who may find it useful?
Offline
Not at all.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I'm using Xdialog but you can use other dialog programs such as xenity or yad. Well everything else is pretty straight forward...feel free to modify the script.
#!/bin/bash
function choose {
PID=`netstat -antuwp|grep -o $PORT.*python|awk '{print $4}'|cut -d'/' -f1`
if [ $PID ]; then
i=`$D --no-tags --radiolist "Options:" 0 0 0 EDIT "Edit list" on STOP "Stop quickserve" off`
else
i=`$D --no-tags --radiolist "Options:" 0 0 0 EDIT "Edit list" on START "Start quickserve" off`
fi
case $i in
EDIT) xdg-open $LIST ;;
STOP) kill $PID ;;
START) startqs ;;
*) exit
esac
choose
}
function startqs {
/usr/bin/quickserve -f $LIST -p $PORT --infopage=/info --upload=/home/user/download -u user --password=password &
sleep 2
netstat -antuwp|grep -o $PORT.*python && $D --infobox "Share can be accessed on port $PORT" 0 0 10000|| $D --msgbox "quickserve could not start." 0 0
}
LIST=/home/user/.quickservefiles
D="Xdialog --stdout --wmclass quickserve --title quickserve --icon /home/user/bin/icons/quickserve.png"
PORT=5905
if [ $# -gt 0 ]; then
if [ -f $LIST ]; then
i=`$D --no-tags --radiolist "A list of sharing files already existed." 0 0 0 NEW "New list" on ADD "Add to existing list" off`
case $i in
NEW) rm $LIST ;;
ADD) ;;
*) exit
esac
fi
for FILE; do
echo "$FILE" >> $LIST
done
fi
choose
Offline
I use it today to upload about 15GB data, works perfectly!
Only one thing missing:
* Progress Bar which tell us how much data is transferred, how much is left and most important. how much time it would take to complete. While uploading so much data, I have no idea when it would finish or worse, it the process still going or stalled for some reason.
I would love to see a Status bar for Uploads
Last edited by cool (2010-02-01 12:49:14)
Offline
Do you mean a progress bar on the client side or the server side?
The client side is handled by whatever application the user is using (web browser, curl, etc) and there is now way for the server to implement a progress bar through standard http.
Displaying a progress bar in the console server-side might be possible, but that would only work for a single connection. If multiple uploads occur simultaneously, it wouldn't work because there is only a single console to print to.
It would be nice to have a progress bar, but I don't see any reasonable way of implementing it. The only possible way that I can think of right now is to generate a progress page that would display information about ongoing uploads, but that would require an overhaul of the code to support threading and shared queues, just to create a page that you would have to keep refreshing (which just adds more load to the server),.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Xyne, thanks for the great tool!
When I use quickserve without username and password, I can browse, download and upload files from my home network and from the outside without problems. However, once I add the username and password, the upload does not work (the rest is ok). I either get "The connection was reset" in firefox, or it asks me to reenter my username and password, but then it does not accept them, and asks me again and again (same behavior in konqueror as well)...
Offline
fixed
It took me a while to see that I had hardcoded 'GET' in the authentication function... I kept looking at the client headers and searching for POST-specific problems.
code blindness -> facepalm -> simple solution
Thanks for report this. It affected Voracious too.
Last edited by Xyne (2010-02-12 01:05:27)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Do you mean a progress bar on the client side or the server side?
The client side is handled by whatever application the user is using (web browser, curl, etc) and there is now way for the server to implement a progress bar through standard http.,.
Its your program, so you decide on how to implement it. so Its upto to you.
I am just saying it would be nice to have a "Progress Bar" while uploading the files;)
Offline
And I am just saying that there is no practical way to do that.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Xyne wrote:Do you mean a progress bar on the client side or the server side?
The client side is handled by whatever application the user is using (web browser, curl, etc) and there is now way for the server to implement a progress bar through standard http.,.
Its your program, so you decide on how to implement it. so Its upto to you.
I am just saying it would be nice to have a "Progress Bar" while uploading the files;)
It really isn't worth all the trouble (I tried implementing it using AJAX). You can always look at the progress bar in the browser's status bar.
@Xyne:
Thank you for sharing your script; it's very useful!
I've been learning Python and I used your script as a basis for creating my own little file server. Python is really starting to grow on me.
EDIT: The authentication system doesn't work with IE. It appears that it's due to how you split the parameters of the authorization header. Your code splits by ', ' but IE doesn't insert a space after the comma. Anyway, I created a patch that uses a regex to extract the parameters, if you're interested. I've tested it on Firefox 3, IE8 and Chromium 4.0.249.89.
--- a/quickserve
+++ b/quickserve
@@ -19,6 +19,7 @@
# METADATA
# Version: 4.2.1
+import re
import cgi, os, os.path, socket
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from hashlib import md5
@@ -74,15 +75,21 @@ class MyHandler(BaseHTTPRequestHandler):
opaque = None
client_response = None
- for field in self.headers['Authorization'][7:].split(', '):
- if field[:10] == 'response="':
- client_response = field[10:-1]
- elif field[:8] == 'cnonce="':
- cnonce = field[8:-1]
- elif field[:3] == 'nc=':
- nc = field[3:]
- elif field[:8] == 'opaque="':
- opaque = field[8:-1]
+ auth_header = self.headers.get('Authorization', '')
+ if auth_header.startswith('Digest '):
+ m = re.findall('(?:(\w+)=(?:"([^"]+)"|([^,\s]+)),?)',
+ auth_header.lstrip('Digest '))
+ # Convert result tuples to dict
+ digest = {}
+ for f in m:
+ digest[f[0]] = f[1] or f[2]
+ try:
+ client_response = digest['response']
+ cnonce = digest['cnonce']
+ nc = digest['nc']
+ opaque = digest['opaque']
+ except KeyError:
+ pass
if client_response != None and cnonce != None and opaque != None and nc != None:
nonce = self.get_nonce(opaque,nc)
Thanks again for sharing!
Last edited by epinull (2010-02-14 23:08:31)
Offline
Thanks epinull.
I decided that it was simpler to just change the split string to "," and add "field = field.strip()" on the next line. Let me know if it works as expected.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Thanks epinull.
I decided that it was simpler to just change the split string to "," and add "field = field.strip()" on the next line. Let me know if it works as expected.
Yeah, I guess I went a little overboard with the regex. Anyway, I just tested it and it works great. Thanks!
Offline
It would be possible to add music streaming support like icecast?
Excuse my poor English.
Offline