You are not logged in.
Polling for new files in a folder (and automatically sharing also them) would be really useful.
Offline
@agapito
Is it possible to stream using standard HTTP requests?
@Ape
It already does that.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Lol, i don't know. I was asking you... It would be a nice feature if could be implemented.
Excuse my poor English.
Offline
I wrote the following script to share files from file manager (using quickserve, of course). The problem is if the script is run from file manager, when the script finish, the terminal close, quickserve is also killed. When I run the script in terminal, I can close the terminal after the script finish and quickserve is still running. I'm a rookie at writing bash script, so I'm sure I must have missed something. Please give me some pointers to start quickserve in the background. Here is my code:
#!/bin/bash
function choose {
PID=`netstat -antuwp|grep -o $PORT.*python|awk '{print $4}'|cut -d'/' -f1`
TEXT="User: $USER \nPassword: $PASS \nPort: $PORT \nPID: $PID"
[ $PID ] && ACTION="Stop quickserve" || ACTION="Start quickserve"
i=`$D --menu "$TEXT" 0 0 0 1 "Edit list" 2 "$ACTION"`
case $i in
1) $EDITOR $LIST ;;
2) [ $PID ] && kill $PID || startqs ;;
*) exit
esac
choose
}
function startqs {
[ $PID ] || quickserve -f $LIST -p $PORT --infopage=/info --upload=/home/tri/download -u $USER --password=$PASS &
sleep 2
}
if tty -s; then
LIST=/home/user/.quickservefiles
D="dialog --stdout --title quickserve"
PORT=5905
USER=user
PASS=password
PID=`netstat -antuwp|grep -o $PORT.*python|awk '{print $4}'|cut -d'/' -f1`
if [ $# -gt 0 ]; then
if [ -f $LIST ]; then
i=`$D --menu "A list of shared files already existed." 0 0 0 1 "Start new list" 2 "Add to existing list"`
echo $i
case $i in
1) rm $LIST ;;
2) ;;
*) exit 1
esac
fi
for FILE; do
[[ "$FILE" = /* ]] && echo "$FILE" >> $LIST || echo $PWD/"$FILE" >> $LIST
done
startqs
else
choose
fi
else
mrxvt -e $0 "$@" &
fi
Offline
Is "file manager" the name of the application or are you referring to a specific file manager?
From a quick glance at the script it looks fine and if it runs as expected from the terminal, the problem probably lies with the application that you're using to launch it, so without knowing exactly which one, I don't have any pointers to give (and might not even if I did know as I tend to run most things from the terminal or via gmrun).
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
The file manager is pcmanfm, but I think it will be the same for any graphical file manager. So how I'm using this is highlight the files I'd like to share in pcmanfm, right click, choose open with the script above. The script runs in terminal and as long as terminal remains open, quickserve is running, but if terminal is close, quickserve stop. Can you add an option to run quickserve as daemon (-d)?
Offline
Try running 'disown' after you start quickserv
Offline
I replace "sleep 2" with "disown", but it still doesn't work. I added "read" after "disown" to keep the terminal open, and quickserve is running while terminal is open, but when I press "enter", terminal close, quickserve stop.
Offline
I'm looking into this right now but so far it seems that the amount of code that I would need to add to enable daemonization is non-trivial. You can get an idea from the following links:
http://www.jejik.com/articles/2007/02/a … in_python/
http://code.activestate.com/recipes/278 … ython-way/
I'm also playing around with the Bash script (e.g. with disown) to try to get it to behave properly as that seems to be the simpler approach in this case.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
That is a lot of additional codes to daemonize it. I don't understand why it works when the script is run fine from terminal but doesn't work when run from file manager. Somehow quickserve PID is tied to "mrxvt -e $0 "$@ &" PID?
Offline
I'm giving up on this for now because I don't have any more time to play with it. It might be worth posting this as a Bash question in the general programming forum.
I'll look into daemonizing the script again later and may take the opportunity to modularize the code to avoid redundancy with Voracious. The only downside to that approach is that neither would remain a single-file script.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
...run quickserve in the background.....
It's solved...the magic command is nohup. So the command for running quickserve in background is something like this
nohup quickserve [options] > /dev/null 2>&1 &; sleep 1
"sleep 1" is needed or quickserve process is still terminated after the shell is closed.
Last edited by tri1976 (2010-03-06 00:44:56)
Offline
Thanks for posting the solution. I had tried nohup but only without the sleep command (obviously).
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I think it's better to add a warning after the Upload button is pressed. A simple javascript can do that:
<body>
<div id="wrapper">
<h1>Upload%(backlink)s%(morelink)s%(fewerlink)s</h1>
<div id="form_wrapper">
<form action="%(back)s" enctype="multipart/form-data" method="post">
%(fields)s
<input class="submit" type="submit" value="Upload" onclick="document.getElementById(\'uploading\').style.display=\'\';"><br><br>
<div id="uploading" style="display:none;text-align:center">Please wait while your file is uploading</div>
</form>
</div>
</div>
</body>
Offline
Thanks, sconosciuto. I've added it to the latest release.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Just found this little gem and can't wipe the smile from my face...it's so simple. Thanks much for writing this!
transcend to the fifth abode
Offline
I'm using the latest version from the AUR and I found a bug.
It send a wrong mimetype to the browser. Something like ('text/html', None). It's because geuss_type() returns a tuple with the mimetype and the encoding. It was fixed for me when I replaced the following on line 277:
if not mimetype:
mimetype = 'application/octet-stream'
With:
if not mimetype:
mimetype = 'application/octet-stream'
else:
mimetype = mimetype[0]
Offline
@ntness
Thanks for the feedback. (Sorry for the late reply. I somehow missed your post.)
@FSX
Thanks. I've fixed it along with a few other bugs that I found and added some other features while I was at it.
## Changelog
### 2010.07.14
* added threading support to handle multiple connection simultaneously
* fixed "Content-Range" bug
* added support for HEAD requests
* re-organized HTML generation
- cleaner code
- W3C XHTML Validation
- W3C CSS Validation
* re-organized startup and info page output
* added icon
* fixed MIMEtype detection bug
* added "Content-Encoding" header
added bonus: media players can now seek through files
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Xyne, this is a very nice app... xD
However, I got this message when sharing a directory with non english characters.
---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 33302) Traceback (most recent call last): File "/usr/lib/python2.6/SocketServer.py", line 281, in _handle_request_noblock self.process_request(request, client_address) File "/usr/lib/python2.6/SocketServer.py", line 307, in process_request self.finish_request(request, client_address) File "/usr/lib/python2.6/SocketServer.py", line 320, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.6/SocketServer.py", line 615, in __init__ self.handle() File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle self.handle_one_request() File "/usr/lib/python2.6/BaseHTTPServer.py", line 323, in handle_one_request method() File "/usr/bin/quickserve", line 102, in do_GET self.wfile.write(html.encode("utf-8")) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 36: ordinal not in range(128) ---------------------------------------- ^C^C received, shutting down server
Is there a way to solve this issue? Thanks.
I got the similar error with the current package build in AUR.
Offline
I got the similar error with the current package build in AUR.
Please post the exact error message and the name of the directory or file that you are trying to serve. Based on your location I assume that you are using Arabic and have therefore tried to reproduce this with both directories and files named "عربي" in various levels of nesting, with and without regular names. I was unable to reproduce the error.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
thanks for your response and sorry for the delay.
>quickserve --port=1998 --filelist=MonthlyExpences2010.ods --username=un --password=test
I am not sure why it is printing all the file data like cat.
雃ٙRcD3.?{*vϩHa>@O20G՞ط:"e}τjX샔w'Ǔ8a
:D笱l
Press <Ctrl-C> to exit.
virgo.lan - - [05/Aug/2010 17:07:18] "GET / HTTP/1.1" 401 -
----------------------------------------
Exception happened during processing of request from ('192.168.1.71', 50785)
Traceback (most recent call last):
File "/usr/lib/python2.6/SocketServer.py", line 558, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.6/SocketServer.py", line 320, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.6/SocketServer.py", line 615, in __init__
self.handle()
File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle
self.handle_one_request()
File "/usr/lib/python2.6/BaseHTTPServer.py", line 323, in handle_one_request
method()
File "/usr/bin/quickserve", line 145, in do_GET
self.do_GET_or_HEAD(True)
File "/usr/bin/quickserve", line 182, in do_GET_or_HEAD
if os.path.isdir(paths[k]):
File "/usr/lib/python2.6/genericpath.py", line 41, in isdir
st = os.stat(s)
TypeError: stat() argument 1 must be encoded string without NULL bytes, not str
----------------------------------------
language is English only. I don't speak Arabic.
Offline
thanks for your response and sorry for the delay.
>quickserve --port=1998 --filelist=MonthlyExpences2010.ods --username=un --password=test
I am not sure why it is printing all the file data like cat.
雃ٙRcD3.?{*vϩHa>@O20G՞ط:"e}τjX샔w'Ǔ8a :D笱l ... TypeError: stat() argument 1 must be encoded string without NULL bytes, not str ----------------------------------------
If you want to share the file "MonthlyExpences2010.ods", remove "--filelist=". The "--filelist" option specifies a file that contains a list of files to share.
Example:
If you want to share "/tmp/foo" and "/tmp/bar", then you would simply run
quickserve /tmp/foo /tmp/bar
Now if you want to stop serving "/tmp/bar" and start serving "/tmp/baz" instead, you would have to restart the server with the new arguments. This is why there is a "--filelist" option. It lets you change the settings dynamically. Using the files in the previous example, you would first create a list, e.g.:
/tmp/serve.txt
/tmp/foo
/tmp/bar
then start the server:
quickserve --filelist=/tmp/serve.txt
Now to stop serving "/tmp/bar" and start serving "/tmp/baz", you would just edit "/tmp/serve.txt":
/tmp/serve.txt
/tmp/foo
/tmp/baz
Quickserve will detect that the file has been updated and begin serving the files in the new list.
The error was caused by the unexpected NULL bytes in the .ods file, which also jumbled the console output when it tried to print the "paths" in that file.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
now clear, thanks.
Offline
I've added SSL (HTTPS) support and moved the base server to it's own module to avoid code reduplication with voracious. I may have introduced new bugs with the numerous changes.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
nice. I will try this.
now the normal one gives the following error when i put the username and password. without username/password server starts fine
quickserve --filelist=/home/<user>/Documents/ToExport.txt --port=2005 --password=test
Starting quickserve...
address: all interfaces
port: 2005
pid: 27637
authentication
Traceback (most recent call last):
File "/usr/bin/quickserve", line 528, in <module>
main(options.address, options.port)
File "/usr/bin/quickserve", line 462, in main
server.display_status()
File "/usr/lib/python2.6/site-packages/XyneHTTPServer.py", line 94, in display_status
print " password: " + options.password
NameError: global name 'options' is not defined
Last edited by kgas (2010-09-18 12:11:58)
Offline