added scripts from other places
This commit is contained in:
parent
18b7f8e039
commit
c0e6891003
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
curl --silent http://torrent.ubuntu.com/simple/precise/server/ | grep beta2 >> /dev/null
|
||||||
|
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
#send mail
|
||||||
|
/home/david/SparkleShare/docs/scripts/telnet_mail.sh "Ubuntu 12.04 Precise Pangolin LTS is out."
|
||||||
|
else
|
||||||
|
echo "still beta2 online"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant_socialnerds.conf
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
dhcpcd wlan0
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#config section
|
||||||
|
|
||||||
|
filename="deleteme.dd"
|
||||||
|
logfile="connection_test.log"
|
||||||
|
|
||||||
|
size="10" #MB
|
||||||
|
#size=$2
|
||||||
|
|
||||||
|
#connection_string="david@dooku.aec.at"
|
||||||
|
connection_string=$1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#functions
|
||||||
|
timestamp()
|
||||||
|
{
|
||||||
|
|
||||||
|
date "+%c"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#script start
|
||||||
|
|
||||||
|
|
||||||
|
echo "[$(timestamp)] - generationg local temp file ($filename)"
|
||||||
|
#appending a "k" to $size
|
||||||
|
size=$(echo $size"k")
|
||||||
|
dd if=/dev/zero of=/tmp/$filename bs=1024 count=$size &> $logfile
|
||||||
|
|
||||||
|
echo "[$(timestamp)] - starting upload test"
|
||||||
|
scp -v /tmp/$filename $connection_string:/tmp/$filename &> $logfile
|
||||||
|
Bps=$(cat deleteme.log | grep "Bytes per second" | awk '{print $5}')
|
||||||
|
count=${#Bps}; count=$((count-1)); Bps=${Bps:0:$count}
|
||||||
|
echo "[$(timestamp)] - upload speed: $Bps Bytes/s"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#clean up
|
||||||
|
echo "[$(timestamp)] - removing temp files"
|
||||||
|
rm /tmp/$filename
|
||||||
|
rm $logfile
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
#end of script
|
|
@ -0,0 +1,124 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# csr.sh: Certificate Signing Request Generator
|
||||||
|
# Copyright(c) 2005 Evaldo Gardenali <evaldo@gardenali.biz>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# 3. Neither the name of the author nor the names of its contributors may
|
||||||
|
# be used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
# ChangeLog:
|
||||||
|
# Mon May 23 00:14:37 BRT 2005 - evaldo - Initial Release
|
||||||
|
|
||||||
|
# be safe about permissions
|
||||||
|
LASTUMASK=`umask`
|
||||||
|
umask 077
|
||||||
|
|
||||||
|
# OpenSSL for HPUX needs a random file
|
||||||
|
RANDOMFILE=$HOME/.rnd
|
||||||
|
|
||||||
|
# create a config file for openssl
|
||||||
|
CONFIG=`mktemp -q /tmp/openssl-conf.XXXXXXXX`
|
||||||
|
if [ ! $? -eq 0 ]; then
|
||||||
|
echo "Could not create temporary config file. exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Private Key and Certificate Signing Request Generator"
|
||||||
|
echo "This script was designed to suit the request format needed by"
|
||||||
|
echo "the CAcert Certificate Authority. www.CAcert.org"
|
||||||
|
echo
|
||||||
|
|
||||||
|
printf "Short Hostname (ie. imap big_srv www2): "
|
||||||
|
read HOST
|
||||||
|
printf "FQDN/CommonName (ie. www.example.com) : "
|
||||||
|
read COMMONNAME
|
||||||
|
|
||||||
|
echo "Type SubjectAltNames for the certificate, one per line. Enter a blank line to finish"
|
||||||
|
SAN=1 # bogus value to begin the loop
|
||||||
|
SANAMES="" # sanitize
|
||||||
|
while [ ! "$SAN" = "" ]; do
|
||||||
|
printf "SubjectAltName: DNS:"
|
||||||
|
read SAN
|
||||||
|
if [ "$SAN" = "" ]; then break; fi # end of input
|
||||||
|
if [ "$SANAMES" = "" ]; then
|
||||||
|
SANAMES="DNS:$SAN"
|
||||||
|
else
|
||||||
|
SANAMES="$SANAMES,DNS:$SAN"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Config File Generation
|
||||||
|
|
||||||
|
cat <<EOF > $CONFIG
|
||||||
|
# -------------- BEGIN custom openssl.cnf -----
|
||||||
|
HOME = $HOME
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ "`uname -s`" = "HP-UX" ]; then
|
||||||
|
echo " RANDFILE = $RANDOMFILE" >> $CONFIG
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> $CONFIG
|
||||||
|
oid_section = new_oids
|
||||||
|
[ new_oids ]
|
||||||
|
[ req ]
|
||||||
|
default_days = 730 # how long to certify for
|
||||||
|
default_keyfile = $HOME/${HOST}_privatekey.pem
|
||||||
|
distinguished_name = req_distinguished_name
|
||||||
|
encrypt_key = no
|
||||||
|
string_mask = nombstr
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ ! "$SANAMES" = "" ]; then
|
||||||
|
echo "req_extensions = v3_req # Extensions to add to certificate request" >> $CONFIG
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> $CONFIG
|
||||||
|
[ req_distinguished_name ]
|
||||||
|
commonName = Common Name (eg, YOUR name)
|
||||||
|
commonName_default = $COMMONNAME
|
||||||
|
commonName_max = 64
|
||||||
|
[ v3_req ]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ ! "$SANAMES" = "" ]; then
|
||||||
|
echo "subjectAltName=$SANAMES" >> $CONFIG
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "# -------------- END custom openssl.cnf -----" >> $CONFIG
|
||||||
|
|
||||||
|
echo "Running OpenSSL..."
|
||||||
|
openssl req -batch -config $CONFIG -newkey rsa:2048 -out $HOME/${HOST}_csr.pem
|
||||||
|
echo "Copy the following Certificate Request and paste into CAcert website to obtain a Certificate."
|
||||||
|
echo "When you receive your certificate, you 'should' name it something like ${HOST}_server.pem"
|
||||||
|
echo
|
||||||
|
cat $HOME/${HOST}_csr.pem
|
||||||
|
echo
|
||||||
|
echo The Certificate request is also available in $HOME/${HOST}_csr.pem
|
||||||
|
echo The Private Key is stored in $HOME/${HOST}_privatekey.pem
|
||||||
|
echo
|
||||||
|
|
||||||
|
rm $CONFIG
|
||||||
|
|
||||||
|
#restore umask
|
||||||
|
umask $LASTUMASK
|
|
@ -0,0 +1,958 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Droopy (http://stackp.online.fr/droopy)
|
||||||
|
# Copyright 2008-2012 (c) Pierre Duquesne <stackp@online.fr>
|
||||||
|
# Licensed under the New BSD License.
|
||||||
|
|
||||||
|
# Changelog
|
||||||
|
# 20120108 * Taiwanese translation by Li-cheng Hsu.
|
||||||
|
# 20110928 * Correctly save message with --save-config. Fix by Sven Radde.
|
||||||
|
# 20110708 * Polish translation by Jacek Politowski.
|
||||||
|
# 20110625 * Fix bug regarding filesystem name encoding.
|
||||||
|
# * Save the --dl option when --save-config is passed.
|
||||||
|
# 20110501 * Add the --dl option to let clients download files.
|
||||||
|
# * CSS speech bubble.
|
||||||
|
# 20101130 * CSS and HTML update. Switch to the new BSD License.
|
||||||
|
# 20100523 * Simplified Chinese translation by Ye Wei.
|
||||||
|
# 20100521 * Hungarian translation by Csaba Szigetvári.
|
||||||
|
# * Russian translation by muromec.
|
||||||
|
# * Use %APPDATA% Windows environment variable -- fix by Maik.
|
||||||
|
# 20091229 * Brazilian Portuguese translation by
|
||||||
|
# Carlos Eduardo Moreira dos Santos and Toony Poony.
|
||||||
|
# * IE layout fix by Carlos Eduardo Moreira dos Santos.
|
||||||
|
# * Galician translation by Miguel Anxo Bouzada.
|
||||||
|
# 20090721 * Indonesian translation by Kemas.
|
||||||
|
# 20090205 * Japanese translation by Satoru Matsumoto.
|
||||||
|
# * Slovak translation by CyberBoBaK.
|
||||||
|
# 20090203 * Norwegian translation by Preben Olav Pedersen.
|
||||||
|
# 20090202 * Korean translation by xissy.
|
||||||
|
# * Fix for unicode filenames by xissy.
|
||||||
|
# * Relies on 127.0.0.1 instead of "localhost" hostname.
|
||||||
|
# 20090129 * Serbian translation by kotnik.
|
||||||
|
# 20090125 * Danish translation by jan.
|
||||||
|
# 20081210 * Greek translation by n2j3.
|
||||||
|
# 20081128 * Slovene translation by david.
|
||||||
|
# * Romanian translation by Licaon.
|
||||||
|
# 20081022 * Swedish translation by David Eurenius.
|
||||||
|
# 20081001 * Droopy gets pretty (css and html rework).
|
||||||
|
# * Finnish translation by ipppe.
|
||||||
|
# 20080926 * Configuration saving and loading.
|
||||||
|
# 20080906 * Extract the file base name (some browsers send the full path).
|
||||||
|
# 20080905 * File is uploaded directly into the specified directory.
|
||||||
|
# 20080904 * Arabic translation by Djalel Chefrour.
|
||||||
|
# * Italian translation by fabius and d1s4st3r.
|
||||||
|
# * Dutch translation by Tonio Voerman.
|
||||||
|
# * Portuguese translation by Pedro Palma.
|
||||||
|
# * Turkish translation by Heartsmagic.
|
||||||
|
# 20080727 * Spanish translation by Federico Kereki.
|
||||||
|
# 20080624 * Option -d or --directory to specify the upload directory.
|
||||||
|
# 20080622 * File numbering to avoid overwriting.
|
||||||
|
# 20080620 * Czech translation by JiÅ™Ã.
|
||||||
|
# * German translation by Michael.
|
||||||
|
# 20080408 * First release.
|
||||||
|
|
||||||
|
import BaseHTTPServer
|
||||||
|
import SocketServer
|
||||||
|
import cgi
|
||||||
|
import os
|
||||||
|
import posixpath
|
||||||
|
import macpath
|
||||||
|
import ntpath
|
||||||
|
import sys
|
||||||
|
import getopt
|
||||||
|
import mimetypes
|
||||||
|
import copy
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
import socket
|
||||||
|
import locale
|
||||||
|
import urllib
|
||||||
|
|
||||||
|
LOGO = '''\
|
||||||
|
_____
|
||||||
|
| \.----.-----.-----.-----.--.--.
|
||||||
|
| -- | _| _ | _ | _ | | |
|
||||||
|
|_____/|__| |_____|_____| __|___ |
|
||||||
|
|__| |_____|
|
||||||
|
'''
|
||||||
|
|
||||||
|
USAGE='''\
|
||||||
|
Usage: droopy [options] [PORT]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help show this help message and exit
|
||||||
|
-d DIRECTORY, --directory DIRECTORY set the directory to upload files to
|
||||||
|
-m MESSAGE, --message MESSAGE set the message
|
||||||
|
-p PICTURE, --picture PICTURE set the picture
|
||||||
|
--dl provide download links
|
||||||
|
--save-config save options in a configuration file
|
||||||
|
--delete-config delete the configuration file and exit
|
||||||
|
|
||||||
|
Example:
|
||||||
|
droopy -m "Hi, this is Bob. You can send me a file." -p avatar.png
|
||||||
|
'''
|
||||||
|
|
||||||
|
picture = None
|
||||||
|
message = ""
|
||||||
|
port = 8000
|
||||||
|
directory = os.curdir
|
||||||
|
must_save_options = False
|
||||||
|
publish_files = False
|
||||||
|
|
||||||
|
# -- HTML templates
|
||||||
|
|
||||||
|
style = '''<style type="text/css">
|
||||||
|
<!--
|
||||||
|
* {margin: 0; padding: 0;}
|
||||||
|
body {text-align: center; background-color: #fff;}
|
||||||
|
.box {padding-top: 20px; padding-bottom: 20px}
|
||||||
|
#linkurl {background-color: #333;}
|
||||||
|
#linkurl a {color: #ddd; text-decoration: none;}
|
||||||
|
#linkurl a:hover {color: #fff;}
|
||||||
|
#message {width: 350px; margin: auto;}
|
||||||
|
#sending {display: none;}
|
||||||
|
#wrapform {height: 90px; padding-top:20px;}
|
||||||
|
#progress {display: inline; border-collapse: separate; empty-cells: show;
|
||||||
|
border-spacing: 10px 0; padding: 0; vertical-align: bottom;}
|
||||||
|
#progress td {height: 25px; width: 23px; background-color: #fff;
|
||||||
|
border: 1px solid #666; padding: 0px;}
|
||||||
|
#userinfo {padding-bottom: 20px;}
|
||||||
|
#files {
|
||||||
|
width: 600px;
|
||||||
|
margin: auto;
|
||||||
|
text-align: left;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
#files a {text-decoration: none}
|
||||||
|
#files a:link {color: #0088ff}
|
||||||
|
#files a:visited {color: #1d548a}
|
||||||
|
#files a:hover {text-decoration: underline}
|
||||||
|
|
||||||
|
/* Speech bubble from http://nicolasgallagher.com/pure-css-speech-bubbles/ */
|
||||||
|
.bubble {
|
||||||
|
position:relative;
|
||||||
|
padding:15px;
|
||||||
|
margin:1em 0 3em;
|
||||||
|
border:1px solid #999;
|
||||||
|
color:#000;
|
||||||
|
background:#fff;
|
||||||
|
/* css3 */
|
||||||
|
-webkit-border-radius:5px;
|
||||||
|
-moz-border-radius:5px;
|
||||||
|
border-radius:5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bubble:before {
|
||||||
|
content:"";
|
||||||
|
position:absolute;
|
||||||
|
bottom:-14px; /* value = - border-top-width - border-bottom-width */
|
||||||
|
left:100px; /* controls horizontal position */
|
||||||
|
border-width:14px 14px 0;
|
||||||
|
border-style:solid;
|
||||||
|
border-color:#333 transparent;
|
||||||
|
/* reduce the damage in FF3.0 */
|
||||||
|
display:block;
|
||||||
|
width:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bubble:after {
|
||||||
|
content:"";
|
||||||
|
position:absolute;
|
||||||
|
bottom:-13px; /* value = - border-top-width - border-bottom-width */
|
||||||
|
left:101px; /* value = (:before left) + (:before border-left) - (:after border-left) */
|
||||||
|
border-width:13px 13px 0;
|
||||||
|
border-style:solid;
|
||||||
|
border-color:#fff transparent;
|
||||||
|
/* reduce the damage in FF3.0 */
|
||||||
|
display:block;
|
||||||
|
width:0;
|
||||||
|
}
|
||||||
|
--></style>'''
|
||||||
|
|
||||||
|
userinfo = '''
|
||||||
|
<div id="userinfo">
|
||||||
|
%(message)s
|
||||||
|
%(divpicture)s
|
||||||
|
</div>
|
||||||
|
'''
|
||||||
|
|
||||||
|
maintmpl = '''<html><head><title>%(maintitle)s</title>
|
||||||
|
''' + style + '''
|
||||||
|
<script language="JavaScript">
|
||||||
|
function swap() {
|
||||||
|
document.getElementById("form").style.display = "none";
|
||||||
|
document.getElementById("sending").style.display = "block";
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
ncell = 4;
|
||||||
|
curcell = 0;
|
||||||
|
function update() {
|
||||||
|
setTimeout(update, 300);
|
||||||
|
e = document.getElementById("cell"+curcell);
|
||||||
|
e.style.backgroundColor = "#fff";
|
||||||
|
curcell = (curcell+1) %% ncell
|
||||||
|
e = document.getElementById("cell"+curcell);
|
||||||
|
e.style.backgroundColor = "#369";
|
||||||
|
}
|
||||||
|
function onunload() {
|
||||||
|
document.getElementById("form").style.display = "block";
|
||||||
|
document.getElementById("sending").style.display = "none";
|
||||||
|
}
|
||||||
|
</script></head>
|
||||||
|
<body>
|
||||||
|
%(linkurl)s
|
||||||
|
<div id="wrapform">
|
||||||
|
<div id="form" class="box">
|
||||||
|
<form method="post" enctype="multipart/form-data" action="">
|
||||||
|
<input name="upfile" type="file">
|
||||||
|
<input value="%(submit)s" onclick="swap()" type="submit">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="sending" class="box"> %(sending)s
|
||||||
|
<table id="progress"><tr>
|
||||||
|
<td id="cell0"/><td id="cell1"/><td id="cell2"/><td id="cell3"/>
|
||||||
|
</tr></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
''' + userinfo + '''
|
||||||
|
%(files)s
|
||||||
|
</body></html>
|
||||||
|
'''
|
||||||
|
|
||||||
|
successtmpl = '''
|
||||||
|
<html>
|
||||||
|
<head><title> %(successtitle)s </title>
|
||||||
|
''' + style + '''
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="wrapform">
|
||||||
|
<div class="box">
|
||||||
|
%(received)s
|
||||||
|
<a href="/"> %(another)s </a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
''' + userinfo + '''
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
'''
|
||||||
|
|
||||||
|
errortmpl = '''
|
||||||
|
<html>
|
||||||
|
<head><title> %(errortitle)s </title>
|
||||||
|
''' + style + '''
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="wrapform">
|
||||||
|
<div class="box">
|
||||||
|
%(problem)s
|
||||||
|
<a href="/"> %(retry)s </a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
''' + userinfo + '''
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
'''
|
||||||
|
|
||||||
|
linkurltmpl = '''<div id="linkurl" class="box">
|
||||||
|
<a href="http://stackp.online.fr/droopy-ip.php?port=%(port)d"> %(discover)s
|
||||||
|
</a></div>'''
|
||||||
|
|
||||||
|
|
||||||
|
templates = {"main": maintmpl, "success": successtmpl, "error": errortmpl}
|
||||||
|
|
||||||
|
# -- Translations
|
||||||
|
|
||||||
|
ar = {"maintitle": u"إرسال ملÙ",
|
||||||
|
"submit": u"إرسال",
|
||||||
|
"sending": u"المل٠قيد الإرسال",
|
||||||
|
"successtitle": u"تم استقبال الملÙ",
|
||||||
|
"received": u"تم استقبال المل٠!",
|
||||||
|
"another": u"إرسال مل٠آخر",
|
||||||
|
"errortitle": u"مشكلة",
|
||||||
|
"problem": u"Øدثت مشكلة !",
|
||||||
|
"retry": u"إعادة المØاولة",
|
||||||
|
"discover": u"اكتشا٠عنوان هذه الصÙØØ©"}
|
||||||
|
|
||||||
|
cs = {"maintitle": u"Poslat soubor",
|
||||||
|
"submit": u"Poslat",
|
||||||
|
"sending": u"PosÃlám",
|
||||||
|
"successtitle": u"Soubor doruÄen",
|
||||||
|
"received": u"Soubor doruÄen !",
|
||||||
|
"another": u"Poslat dalšà soubor",
|
||||||
|
"errortitle": u"Chyba",
|
||||||
|
"problem": u"Stala se chyba !",
|
||||||
|
"retry": u"Zkusit znova.",
|
||||||
|
"discover": u"Zjistit adresu stránky"}
|
||||||
|
|
||||||
|
da = {"maintitle": u"Send en fil",
|
||||||
|
"submit": u"Send",
|
||||||
|
"sending": u"Sender",
|
||||||
|
"successtitle": u"Fil modtaget",
|
||||||
|
"received": u"Fil modtaget!",
|
||||||
|
"another": u"Send en fil til.",
|
||||||
|
"errortitle": u"Problem",
|
||||||
|
"problem": u"Det er opstået en fejl!",
|
||||||
|
"retry": u"Forsøg igen.",
|
||||||
|
"discover": u"Find adressen til denne side"}
|
||||||
|
|
||||||
|
de = {"maintitle": "Datei senden",
|
||||||
|
"submit": "Senden",
|
||||||
|
"sending": "Sendet",
|
||||||
|
"successtitle": "Datei empfangen",
|
||||||
|
"received": "Datei empfangen!",
|
||||||
|
"another": "Weitere Datei senden",
|
||||||
|
"errortitle": "Fehler",
|
||||||
|
"problem": "Ein Fehler ist aufgetreten!",
|
||||||
|
"retry": "Wiederholen",
|
||||||
|
"discover": "Internet-Adresse dieser Seite feststellen"}
|
||||||
|
|
||||||
|
el = {"maintitle": u"Στείλε Îνα αÏχείο",
|
||||||
|
"submit": u"Αποστολή",
|
||||||
|
"sending": u"ΑποστÎλλεται...",
|
||||||
|
"successtitle": u"Επιτυχής λήψη αÏχείου ",
|
||||||
|
"received": u"Λήψη αÏχείου ολοκληÏώθηκε",
|
||||||
|
"another": u"Στείλε άλλο Îνα αÏχείο",
|
||||||
|
"errortitle": u"Σφάλμα",
|
||||||
|
"problem": u"ΠαÏουσιάστηκε σφάλμα",
|
||||||
|
"retry": u"Επανάληψη",
|
||||||
|
"discover": u"Î’Ïες την διεÏθυνση της σελίδας"}
|
||||||
|
|
||||||
|
en = {"maintitle": "Send a file",
|
||||||
|
"submit": "Send",
|
||||||
|
"sending": "Sending",
|
||||||
|
"successtitle": "File received",
|
||||||
|
"received": "File received !",
|
||||||
|
"another": "Send another file.",
|
||||||
|
"errortitle": "Problem",
|
||||||
|
"problem": "There has been a problem !",
|
||||||
|
"retry": "Retry.",
|
||||||
|
"discover": "Discover the address of this page"}
|
||||||
|
|
||||||
|
es = {"maintitle": u"Enviar un archivo",
|
||||||
|
"submit": u"Enviar",
|
||||||
|
"sending": u"Enviando",
|
||||||
|
"successtitle": u"Archivo recibido",
|
||||||
|
"received": u"¡Archivo recibido!",
|
||||||
|
"another": u"Enviar otro archivo.",
|
||||||
|
"errortitle": u"Error",
|
||||||
|
"problem": u"¡Hubo un problema!",
|
||||||
|
"retry": u"Reintentar",
|
||||||
|
"discover": u"Descubrir la dirección de esta página"}
|
||||||
|
|
||||||
|
fi = {"maintitle": u"Lähetä tiedosto",
|
||||||
|
"submit": u"Lähetä",
|
||||||
|
"sending": u"Lähettää",
|
||||||
|
"successtitle": u"Tiedosto vastaanotettu",
|
||||||
|
"received": u"Tiedosto vastaanotettu!",
|
||||||
|
"another": u"Lähetä toinen tiedosto.",
|
||||||
|
"errortitle": u"Virhe",
|
||||||
|
"problem": u"Virhe lahetettäessä tiedostoa!",
|
||||||
|
"retry": u"Uudelleen.",
|
||||||
|
"discover": u"Näytä tämän sivun osoite"}
|
||||||
|
|
||||||
|
fr = {"maintitle": u"Envoyer un fichier",
|
||||||
|
"submit": u"Envoyer",
|
||||||
|
"sending": u"Envoi en cours",
|
||||||
|
"successtitle": u"Fichier reçu",
|
||||||
|
"received": u"Fichier reçu !",
|
||||||
|
"another": u"Envoyer un autre fichier.",
|
||||||
|
"errortitle": u"Problème",
|
||||||
|
"problem": u"Il y a eu un problème !",
|
||||||
|
"retry": u"Réessayer.",
|
||||||
|
"discover": u"Découvrir l'adresse de cette page"}
|
||||||
|
|
||||||
|
gl = {"maintitle": u"Enviar un ficheiro",
|
||||||
|
"submit": u"Enviar",
|
||||||
|
"sending": u"Enviando",
|
||||||
|
"successtitle": u"Ficheiro recibido",
|
||||||
|
"received": u"Ficheiro recibido!",
|
||||||
|
"another": u"Enviar outro ficheiro.",
|
||||||
|
"errortitle": u"Erro",
|
||||||
|
"problem": u"XurdÃu un problema!",
|
||||||
|
"retry": u"Reintentar",
|
||||||
|
"discover": u"Descubrir o enderezo desta páxina"}
|
||||||
|
|
||||||
|
hu = {"maintitle": u"Ãllomány küldése",
|
||||||
|
"submit": u"Küldés",
|
||||||
|
"sending": u"Küldés folyamatban",
|
||||||
|
"successtitle": u"Az állomány beérkezett",
|
||||||
|
"received": u"Az állomány beérkezett!",
|
||||||
|
"another": u"További állományok küldése",
|
||||||
|
"errortitle": u"Hiba",
|
||||||
|
"problem": u"Egy hiba lépett fel!",
|
||||||
|
"retry": u"Megismételni",
|
||||||
|
"discover": u"Az oldal Internet-cÃmének megállapÃtása"}
|
||||||
|
|
||||||
|
id = {"maintitle": "Kirim sebuah berkas",
|
||||||
|
"submit": "Kirim",
|
||||||
|
"sending": "Mengirim",
|
||||||
|
"successtitle": "Berkas diterima",
|
||||||
|
"received": "Berkas diterima!",
|
||||||
|
"another": "Kirim berkas yang lain.",
|
||||||
|
"errortitle": "Permasalahan",
|
||||||
|
"problem": "Telah ditemukan sebuah kesalahan!",
|
||||||
|
"retry": "Coba kembali.",
|
||||||
|
"discover": "Kenali alamat IP dari halaman ini"}
|
||||||
|
|
||||||
|
it = {"maintitle": u"Invia un file",
|
||||||
|
"submit": u"Invia",
|
||||||
|
"sending": u"Invio in corso",
|
||||||
|
"successtitle": u"File ricevuto",
|
||||||
|
"received": u"File ricevuto!",
|
||||||
|
"another": u"Invia un altro file.",
|
||||||
|
"errortitle": u"Errore",
|
||||||
|
"problem": u"Si è verificato un errore!",
|
||||||
|
"retry": u"Riprova.",
|
||||||
|
"discover": u"Scopri l’indirizzo di questa pagina"}
|
||||||
|
|
||||||
|
ja = {"maintitle": u"ファイルé€ä¿¡",
|
||||||
|
"submit": u"é€ä¿¡",
|
||||||
|
"sending": u"é€ä¿¡ä¸",
|
||||||
|
"successtitle": u"å—信完了",
|
||||||
|
"received": u"ファイルをå—ä¿¡ã—ã¾ã—ãŸï¼",
|
||||||
|
"another": u"ä»–ã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’é€ä¿¡ã™ã‚‹",
|
||||||
|
"errortitle": u"å•é¡Œç™ºç”Ÿ",
|
||||||
|
"problem": u"å•é¡ŒãŒç™ºç”Ÿã—ã¾ã—ãŸï¼",
|
||||||
|
"retry": u"リトライ",
|
||||||
|
"discover": u"ã“ã®ãƒšãƒ¼ã‚¸ã®ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’確èªã™ã‚‹"}
|
||||||
|
|
||||||
|
ko = {"maintitle": u"íŒŒì¼ ë³´ë‚´ê¸°",
|
||||||
|
"submit": u"보내기",
|
||||||
|
"sending": u"보내는 중",
|
||||||
|
"successtitle": u"파ì¼ì´ 받아졌습니다",
|
||||||
|
"received": u"파ì¼ì´ 받아졌습니다!",
|
||||||
|
"another": u"다른 íŒŒì¼ ë³´ë‚´ê¸°",
|
||||||
|
"errortitle": u"ë¬¸ì œê°€ ë°œìƒí–ˆìŠµë‹ˆë‹¤",
|
||||||
|
"problem": u"ë¬¸ì œê°€ ë°œìƒí–ˆìŠµë‹ˆë‹¤!",
|
||||||
|
"retry": u"다시 ì‹œë„",
|
||||||
|
"discover": u"ì´ íŽ˜ì´ì§€ 주소 알아보기"}
|
||||||
|
|
||||||
|
nl = {"maintitle": "Verstuur een bestand",
|
||||||
|
"submit": "Verstuur",
|
||||||
|
"sending": "Bezig met versturen",
|
||||||
|
"successtitle": "Bestand ontvangen",
|
||||||
|
"received": "Bestand ontvangen!",
|
||||||
|
"another": "Verstuur nog een bestand.",
|
||||||
|
"errortitle": "Fout",
|
||||||
|
"problem": "Er is een fout opgetreden!",
|
||||||
|
"retry": "Nog eens.",
|
||||||
|
"discover": "Vind het adres van deze pagina"}
|
||||||
|
|
||||||
|
no = {"maintitle": u"Send en fil",
|
||||||
|
"submit": u"Send",
|
||||||
|
"sending": u"Sender",
|
||||||
|
"successtitle": u"Fil mottatt",
|
||||||
|
"received": u"Fil mottatt !",
|
||||||
|
"another": u"Send en ny fil.",
|
||||||
|
"errortitle": u"Feil",
|
||||||
|
"problem": u"Det har skjedd en feil !",
|
||||||
|
"retry": u"Send på nytt.",
|
||||||
|
"discover": u"Finn addressen til denne siden"}
|
||||||
|
|
||||||
|
pl = {"maintitle": u"Wyślij plik",
|
||||||
|
"submit": u"Wyślij",
|
||||||
|
"sending": u"Wysyłanie",
|
||||||
|
"successtitle": u"Plik wysłany",
|
||||||
|
"received": u"Plik wysłany!",
|
||||||
|
"another": u"Wyślij kolejny plik.",
|
||||||
|
"errortitle": u"Problem",
|
||||||
|
"problem": u"Wystąpił błąd!",
|
||||||
|
"retry": u"Spróbuj ponownie.",
|
||||||
|
"discover": u"Znajdź adres tej strony"}
|
||||||
|
|
||||||
|
pt = {"maintitle": u"Enviar um ficheiro",
|
||||||
|
"submit": u"Enviar",
|
||||||
|
"sending": u"A enviar",
|
||||||
|
"successtitle": u"Ficheiro recebido",
|
||||||
|
"received": u"Ficheiro recebido !",
|
||||||
|
"another": u"Enviar outro ficheiro.",
|
||||||
|
"errortitle": u"Erro",
|
||||||
|
"problem": u"Ocorreu um erro !",
|
||||||
|
"retry": u"Tentar novamente.",
|
||||||
|
"discover": u"Descobrir o endereço desta página"}
|
||||||
|
|
||||||
|
pt_br = {
|
||||||
|
"maintitle": u"Enviar um arquivo",
|
||||||
|
"submit": u"Enviar",
|
||||||
|
"sending": u"Enviando",
|
||||||
|
"successtitle": u"Arquivo recebido",
|
||||||
|
"received": u"Arquivo recebido!",
|
||||||
|
"another": u"Enviar outro arquivo.",
|
||||||
|
"errortitle": u"Erro",
|
||||||
|
"problem": u"Ocorreu um erro!",
|
||||||
|
"retry": u"Tentar novamente.",
|
||||||
|
"discover": u"Descobrir o endereço desta página"}
|
||||||
|
|
||||||
|
ro = {"maintitle": u"Trimite un fiÅŸier",
|
||||||
|
"submit": u"Trimite",
|
||||||
|
"sending": u"Se trimite",
|
||||||
|
"successtitle": u"Fişier recepţionat",
|
||||||
|
"received": u"Fişier recepţionat !",
|
||||||
|
"another": u"Trimite un alt fiÅŸier.",
|
||||||
|
"errortitle": u"Problemă",
|
||||||
|
"problem": u"A intervenit o problemă !",
|
||||||
|
"retry": u"Reîncearcă.",
|
||||||
|
"discover": u"Descoperă adresa acestei pagini"}
|
||||||
|
|
||||||
|
ru = {"maintitle": u"Отправить файл",
|
||||||
|
"submit": u"Отправить",
|
||||||
|
"sending": u"ОтправлÑÑŽ",
|
||||||
|
"successtitle": u"Файл получен",
|
||||||
|
"received": u"Файл получен !",
|
||||||
|
"another": u"Отправить другой файл.",
|
||||||
|
"errortitle": u"Ошибка",
|
||||||
|
"problem": u"Произошла ошибка !",
|
||||||
|
"retry": u"Повторить.",
|
||||||
|
"discover": u"ПоÑмотреть Ð°Ð´Ñ€ÐµÑ Ñтой Ñтраницы"}
|
||||||
|
|
||||||
|
sk = {"maintitle": u"Pošli súbor",
|
||||||
|
"submit": u"Pošli",
|
||||||
|
"sending": u"Posielam",
|
||||||
|
"successtitle": u"Súbor prijatý",
|
||||||
|
"received": u"Súbor prijatý !",
|
||||||
|
"another": u"PoslaÅ¥ ÄalÅ¡Ã súbor.",
|
||||||
|
"errortitle": u"Chyba",
|
||||||
|
"problem": u"Vyskytla sa chyba!",
|
||||||
|
"retry": u"Skúsiť znova.",
|
||||||
|
"discover": u"Zisti adresu tejto stránky"}
|
||||||
|
|
||||||
|
sl = {"maintitle": u"Pošlji datoteko",
|
||||||
|
"submit": u"Pošlji",
|
||||||
|
"sending": u"Pošiljam",
|
||||||
|
"successtitle": u"Datoteka prejeta",
|
||||||
|
"received": u"Datoteka prejeta !",
|
||||||
|
"another": u"Pošlji novo datoteko.",
|
||||||
|
"errortitle": u"Napaka",
|
||||||
|
"problem": u"Prišlo je do napake !",
|
||||||
|
"retry": u"Poizkusi ponovno.",
|
||||||
|
"discover": u"PoiÅ¡Äi naslov na tej strani"}
|
||||||
|
|
||||||
|
sr = {"maintitle": u"Pošalji fajl",
|
||||||
|
"submit": u"Pošalji",
|
||||||
|
"sending": u"Å aljem",
|
||||||
|
"successtitle": u"Fajl primljen",
|
||||||
|
"received": u"Fajl primljen !",
|
||||||
|
"another": u"Pošalji još jedan fajl.",
|
||||||
|
"errortitle": u"Problem",
|
||||||
|
"problem": u"Desio se problem !",
|
||||||
|
"retry": u"Pokušaj ponovo.",
|
||||||
|
"discover": u"Otkrij adresu ove stranice"}
|
||||||
|
|
||||||
|
sv = {"maintitle": u"Skicka en fil",
|
||||||
|
"submit": u"Skicka",
|
||||||
|
"sending": u"Skickar...",
|
||||||
|
"successtitle": u"Fil mottagen",
|
||||||
|
"received": u"Fil mottagen !",
|
||||||
|
"another": u"Skicka en fil till.",
|
||||||
|
"errortitle": u"Fel",
|
||||||
|
"problem": u"Det har uppstått ett fel !",
|
||||||
|
"retry": u"Försök igen.",
|
||||||
|
"discover": u"Ta reda på adressen till denna sida"}
|
||||||
|
|
||||||
|
tr = {"maintitle": u"Dosya gönder",
|
||||||
|
"submit": u"Gönder",
|
||||||
|
"sending": u"Gönderiliyor...",
|
||||||
|
"successtitle": u"Gönderildi",
|
||||||
|
"received": u"Gönderildi",
|
||||||
|
"another": u"Başka bir dosya gönder.",
|
||||||
|
"errortitle": u"Problem.",
|
||||||
|
"problem": u"Bir problem oldu !",
|
||||||
|
"retry": u"Yeniden dene.",
|
||||||
|
"discover": u"Bu sayfanın adresini bul"}
|
||||||
|
|
||||||
|
zh_cn = {
|
||||||
|
"maintitle": u"å‘é€æ–‡ä»¶",
|
||||||
|
"submit": u"å‘é€",
|
||||||
|
"sending": u"å‘é€ä¸",
|
||||||
|
"successtitle": u"文件已收到",
|
||||||
|
"received": u"文件已收到ï¼",
|
||||||
|
"another": u"å‘é€å¦ä¸€ä¸ªæ–‡ä»¶ã€‚",
|
||||||
|
"errortitle": u"问题",
|
||||||
|
"problem": u"出现问题ï¼",
|
||||||
|
"retry": u"é‡è¯•ã€‚",
|
||||||
|
"discover": u"查看本页é¢çš„地å€"}
|
||||||
|
|
||||||
|
zh_tw = {
|
||||||
|
"maintitle": u"上傳檔案",
|
||||||
|
"submit": u"上傳",
|
||||||
|
"sending": u"傳é€ä¸...",
|
||||||
|
"successtitle": u"已收到檔案",
|
||||||
|
"received": u"已收到檔案ï¼",
|
||||||
|
"another": u"上傳å¦ä¸€å€‹æª”案。",
|
||||||
|
"errortitle": u"錯誤",
|
||||||
|
"problem": u"出ç¾éŒ¯èª¤ï¼",
|
||||||
|
"retry": u"é‡è©¦ã€‚",
|
||||||
|
"discover": u"查閱本網é 的網å€"}
|
||||||
|
|
||||||
|
translations = {"ar": ar, "cs": cs, "da": da, "de": de, "el": el, "en": en,
|
||||||
|
"es": es, "fi": fi, "fr": fr, "gl": gl, "hu": hu, "id": id,
|
||||||
|
"it": it, "ja": ja, "ko": ko, "nl": nl, "no": no, "pl": pl,
|
||||||
|
"pt": pt, "pt-br": pt_br, "ro": ro, "ru": ru, "sk": sk,
|
||||||
|
"sl": sl, "sr": sr, "sv": sv, "tr": tr, "zh-cn": zh_cn,
|
||||||
|
"zh-tw": zh_tw}
|
||||||
|
|
||||||
|
|
||||||
|
class DroopyFieldStorage(cgi.FieldStorage):
|
||||||
|
"""The file is created in the destination directory and its name is
|
||||||
|
stored in the tmpfilename attribute.
|
||||||
|
"""
|
||||||
|
|
||||||
|
TMPPREFIX = 'tmpdroopy'
|
||||||
|
|
||||||
|
def make_file(self, binary=None):
|
||||||
|
fd, name = tempfile.mkstemp(dir=directory, prefix=self.TMPPREFIX)
|
||||||
|
self.tmpfile = os.fdopen(fd, 'w+b')
|
||||||
|
self.tmpfilename = name
|
||||||
|
return self.tmpfile
|
||||||
|
|
||||||
|
|
||||||
|
class HTTPUploadHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
|
|
||||||
|
protocol_version = 'HTTP/1.0'
|
||||||
|
form_field = 'upfile'
|
||||||
|
divpicture = '<div class="box"><img src="/__droopy/picture"/></div>'
|
||||||
|
|
||||||
|
|
||||||
|
def html(self, page):
|
||||||
|
"""
|
||||||
|
page can be "main", "success", or "error"
|
||||||
|
returns an html page (in the appropriate language) as a string
|
||||||
|
"""
|
||||||
|
|
||||||
|
# -- Parse accept-language header
|
||||||
|
if not self.headers.has_key("accept-language"):
|
||||||
|
a = []
|
||||||
|
else:
|
||||||
|
a = self.headers["accept-language"]
|
||||||
|
a = a.split(',')
|
||||||
|
a = [e.split(';q=') for e in a]
|
||||||
|
a = [(lambda x: len(x)==1 and (1, x[0]) or
|
||||||
|
(float(x[1]), x[0])) (e) for e in a]
|
||||||
|
a.sort()
|
||||||
|
a.reverse()
|
||||||
|
a = [x[1] for x in a]
|
||||||
|
# now a is an ordered list of preferred languages
|
||||||
|
|
||||||
|
# -- Choose the appropriate translation dictionary (default is english)
|
||||||
|
lang = "en"
|
||||||
|
for l in a:
|
||||||
|
if translations.has_key(l):
|
||||||
|
lang = l
|
||||||
|
break
|
||||||
|
dico = copy.copy(translations[lang])
|
||||||
|
|
||||||
|
# -- Set message and picture
|
||||||
|
if message:
|
||||||
|
dico["message"] = ('<div id="message" class="bubble">%s</div>' %
|
||||||
|
message)
|
||||||
|
else:
|
||||||
|
dico["message"] = ""
|
||||||
|
|
||||||
|
if picture != None:
|
||||||
|
dico["divpicture"] = self.divpicture
|
||||||
|
else:
|
||||||
|
dico["divpicture"] = ""
|
||||||
|
|
||||||
|
# -- Possibly provide download links
|
||||||
|
links = ""
|
||||||
|
names = self.published_files()
|
||||||
|
if names:
|
||||||
|
for name in names:
|
||||||
|
links += '<a href="/%s">%s</a><br/>' % (
|
||||||
|
urllib.quote(name.encode('utf-8')),
|
||||||
|
name)
|
||||||
|
links = '<div id="files">' + links + '</div>'
|
||||||
|
dico["files"] = links
|
||||||
|
|
||||||
|
# -- Add a link to discover the url
|
||||||
|
if self.client_address[0] == "127.0.0.1":
|
||||||
|
dico["port"] = self.server.server_port
|
||||||
|
dico["linkurl"] = linkurltmpl % dico
|
||||||
|
else:
|
||||||
|
dico["linkurl"] = ""
|
||||||
|
|
||||||
|
return templates[page] % dico
|
||||||
|
|
||||||
|
|
||||||
|
def do_GET(self):
|
||||||
|
name = self.path.lstrip('/')
|
||||||
|
name = urllib.unquote(name)
|
||||||
|
name = name.decode('utf-8')
|
||||||
|
|
||||||
|
if picture != None and self.path == '/__droopy/picture':
|
||||||
|
# send the picture
|
||||||
|
self.send_file(picture)
|
||||||
|
|
||||||
|
elif name in self.published_files():
|
||||||
|
localpath = os.path.join(directory, name)
|
||||||
|
self.send_file(localpath)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.send_html(self.html("main"))
|
||||||
|
|
||||||
|
|
||||||
|
def do_POST(self):
|
||||||
|
# Do some browsers /really/ use multipart ? maybe Opera ?
|
||||||
|
try:
|
||||||
|
self.log_message("Started file transfer")
|
||||||
|
|
||||||
|
# -- Set up environment for cgi.FieldStorage
|
||||||
|
env = {}
|
||||||
|
env['REQUEST_METHOD'] = self.command
|
||||||
|
if self.headers.typeheader is None:
|
||||||
|
env['CONTENT_TYPE'] = self.headers.type
|
||||||
|
else:
|
||||||
|
env['CONTENT_TYPE'] = self.headers.typeheader
|
||||||
|
|
||||||
|
# -- Save file (numbered to avoid overwriting, ex: foo-3.png)
|
||||||
|
form = DroopyFieldStorage(fp = self.rfile, environ = env);
|
||||||
|
fileitem = form[self.form_field]
|
||||||
|
filename = self.basename(fileitem.filename).decode('utf-8')
|
||||||
|
if filename == "":
|
||||||
|
self.send_response(303)
|
||||||
|
self.send_header('Location', '/')
|
||||||
|
self.end_headers()
|
||||||
|
return
|
||||||
|
|
||||||
|
localpath = os.path.join(directory, filename).encode('utf-8')
|
||||||
|
root, ext = os.path.splitext(localpath)
|
||||||
|
i = 1
|
||||||
|
# race condition, but hey...
|
||||||
|
while (os.path.exists(localpath)):
|
||||||
|
localpath = "%s-%d%s" % (root, i, ext)
|
||||||
|
i = i+1
|
||||||
|
if hasattr(fileitem, 'tmpfile'):
|
||||||
|
# DroopyFieldStorage.make_file() has been called
|
||||||
|
fileitem.tmpfile.close()
|
||||||
|
shutil.move(fileitem.tmpfilename, localpath)
|
||||||
|
else:
|
||||||
|
# no temporary file, self.file is a StringIO()
|
||||||
|
# see cgi.FieldStorage.read_lines()
|
||||||
|
fout = file(localpath, 'wb')
|
||||||
|
shutil.copyfileobj(fileitem.file, fout)
|
||||||
|
fout.close()
|
||||||
|
self.log_message("Received: %s", os.path.basename(localpath))
|
||||||
|
|
||||||
|
# -- Reply
|
||||||
|
if publish_files:
|
||||||
|
# The file list gives a feedback for the upload
|
||||||
|
# success
|
||||||
|
self.send_response(301)
|
||||||
|
self.send_header("Location", "/")
|
||||||
|
self.end_headers()
|
||||||
|
else:
|
||||||
|
self.send_html(self.html("success"))
|
||||||
|
|
||||||
|
except Exception, e:
|
||||||
|
self.log_message(repr(e))
|
||||||
|
self.send_html(self.html("error"))
|
||||||
|
|
||||||
|
|
||||||
|
def send_html(self, htmlstr):
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-type','text/html; charset=utf-8')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(htmlstr.encode('utf-8'))
|
||||||
|
|
||||||
|
def send_file(self, localpath):
|
||||||
|
f = open(localpath, 'rb')
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-type',
|
||||||
|
mimetypes.guess_type(localpath)[0])
|
||||||
|
self.send_header('Content-length', os.fstat(f.fileno())[6])
|
||||||
|
self.end_headers()
|
||||||
|
shutil.copyfileobj(f, self.wfile)
|
||||||
|
|
||||||
|
def basename(self, path):
|
||||||
|
"""Extract the file base name (some browsers send the full file path).
|
||||||
|
"""
|
||||||
|
for mod in posixpath, macpath, ntpath:
|
||||||
|
path = mod.basename(path)
|
||||||
|
return path
|
||||||
|
|
||||||
|
def published_files(self):
|
||||||
|
"""Returns the list of files that should appear as download links.
|
||||||
|
|
||||||
|
The returned filenames are unicode strings.
|
||||||
|
"""
|
||||||
|
if publish_files:
|
||||||
|
# os.listdir() returns a list of unicode strings when the
|
||||||
|
# directory is passed as an unicode string itself.
|
||||||
|
names = [name for name in os.listdir(unicode(directory))
|
||||||
|
if os.path.isfile(os.path.join(directory, name))
|
||||||
|
and not name.startswith(DroopyFieldStorage.TMPPREFIX)]
|
||||||
|
names.sort()
|
||||||
|
else:
|
||||||
|
names = []
|
||||||
|
return names
|
||||||
|
|
||||||
|
def handle(self):
|
||||||
|
try:
|
||||||
|
BaseHTTPServer.BaseHTTPRequestHandler.handle(self)
|
||||||
|
except socket.error, e:
|
||||||
|
self.log_message(str(e))
|
||||||
|
raise Abort()
|
||||||
|
|
||||||
|
|
||||||
|
class Abort(Exception): pass
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadedHTTPServer(SocketServer.ThreadingMixIn,
|
||||||
|
BaseHTTPServer.HTTPServer):
|
||||||
|
|
||||||
|
def handle_error(self, request, client_address):
|
||||||
|
# Override SocketServer.handle_error
|
||||||
|
exctype = sys.exc_info()[0]
|
||||||
|
if not exctype is Abort:
|
||||||
|
BaseHTTPServer.HTTPServer.handle_error(self,request,client_address)
|
||||||
|
|
||||||
|
|
||||||
|
# -- Options
|
||||||
|
|
||||||
|
def configfile():
|
||||||
|
appname = 'droopy'
|
||||||
|
# os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
|
||||||
|
if os.name == 'posix':
|
||||||
|
filename = "%s/.%s" % (os.environ["HOME"], appname)
|
||||||
|
|
||||||
|
elif os.name == 'mac':
|
||||||
|
filename = ("%s/Library/Application Support/%s" %
|
||||||
|
(os.environ["HOME"], appname))
|
||||||
|
|
||||||
|
elif os.name == 'nt':
|
||||||
|
filename = ("%s\%s" % (os.environ["APPDATA"], appname))
|
||||||
|
|
||||||
|
else:
|
||||||
|
filename = None
|
||||||
|
|
||||||
|
return filename
|
||||||
|
|
||||||
|
|
||||||
|
def save_options():
|
||||||
|
opt = []
|
||||||
|
if message:
|
||||||
|
opt.append('--message=%s' % message.replace('\n', '\\n'))
|
||||||
|
if picture:
|
||||||
|
opt.append('--picture=%s' % picture)
|
||||||
|
if directory:
|
||||||
|
opt.append('--directory=%s' % directory)
|
||||||
|
if publish_files:
|
||||||
|
opt.append('--dl')
|
||||||
|
if port:
|
||||||
|
opt.append('%d' % port)
|
||||||
|
f = open(configfile(), 'w')
|
||||||
|
f.write('\n'.join(opt).encode('utf8'))
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
def load_options():
|
||||||
|
try:
|
||||||
|
f = open(configfile())
|
||||||
|
cmd = [line.strip().decode('utf8').replace('\\n', '\n')
|
||||||
|
for line in f.readlines()]
|
||||||
|
parse_args(cmd)
|
||||||
|
f.close()
|
||||||
|
return True
|
||||||
|
except IOError, e:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args(cmd=None):
|
||||||
|
"""Parse command-line arguments.
|
||||||
|
|
||||||
|
Parse sys.argv[1:] if no argument is passed.
|
||||||
|
"""
|
||||||
|
global picture, message, port, directory, must_save_options, publish_files
|
||||||
|
|
||||||
|
if cmd == None:
|
||||||
|
cmd = sys.argv[1:]
|
||||||
|
lang, encoding = locale.getdefaultlocale()
|
||||||
|
if encoding != None:
|
||||||
|
cmd = [a.decode(encoding) for a in cmd]
|
||||||
|
|
||||||
|
opts, args = None, None
|
||||||
|
try:
|
||||||
|
opts, args = getopt.gnu_getopt(cmd, "p:m:d:h",
|
||||||
|
["picture=","message=",
|
||||||
|
"directory=", "help",
|
||||||
|
"save-config","delete-config",
|
||||||
|
"dl"])
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for o,a in opts:
|
||||||
|
if o in ["-p", "--picture"] :
|
||||||
|
picture = os.path.expanduser(a)
|
||||||
|
|
||||||
|
elif o in ["-m", "--message"] :
|
||||||
|
message = a
|
||||||
|
|
||||||
|
elif o in ['-d', '--directory']:
|
||||||
|
directory = a
|
||||||
|
|
||||||
|
elif o in ['--save-config']:
|
||||||
|
must_save_options = True
|
||||||
|
|
||||||
|
elif o in ['--delete-config']:
|
||||||
|
try:
|
||||||
|
filename = configfile()
|
||||||
|
os.remove(filename)
|
||||||
|
print 'Deleted ' + filename
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
elif o in ['--dl']:
|
||||||
|
publish_files = True
|
||||||
|
|
||||||
|
elif o in ['-h', '--help']:
|
||||||
|
print USAGE
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# port number
|
||||||
|
try:
|
||||||
|
if args[0:]:
|
||||||
|
port = int(args[0])
|
||||||
|
except ValueError:
|
||||||
|
print args[0], "is not a valid port number"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
# --
|
||||||
|
|
||||||
|
def run():
|
||||||
|
"""Run the webserver."""
|
||||||
|
socket.setdefaulttimeout(3*60)
|
||||||
|
server_address = ('', port)
|
||||||
|
httpd = ThreadedHTTPServer(server_address, HTTPUploadHandler)
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print LOGO
|
||||||
|
|
||||||
|
config_found = load_options()
|
||||||
|
parse_args()
|
||||||
|
|
||||||
|
if config_found:
|
||||||
|
print 'Configuration found in %s' % configfile()
|
||||||
|
else:
|
||||||
|
print "No configuration file found."
|
||||||
|
|
||||||
|
if must_save_options:
|
||||||
|
save_options()
|
||||||
|
print "Options saved in %s" % configfile()
|
||||||
|
|
||||||
|
print "Files will be uploaded to %s" % directory
|
||||||
|
try:
|
||||||
|
print
|
||||||
|
print "HTTP server running... Check it out at http://localhost:%d"%port
|
||||||
|
run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print '^C received, shutting down server'
|
||||||
|
# some threads may run until they terminate
|
|
@ -0,0 +1,8 @@
|
||||||
|
#/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
sshfs -o idmap=user $USER@kitt.socialnerds.org:/srv/storage/david/audio ~/tomahawk
|
||||||
|
|
||||||
|
tomahawk &
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
net use S: \\wh13.aec.at\AE-Solutions /PERSISTENT:yes
|
||||||
|
|
||||||
|
#net use S: \\wh13.aec.at\systembetrieb /PERSISTENT:yes
|
|
@ -0,0 +1,68 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
# Author: Dominik Danter
|
||||||
|
# Version: 0.01
|
||||||
|
# Purpose:
|
||||||
|
# Tiny VLC wrapper that streams the file provided as argument. This can be used
|
||||||
|
# as a Nautlius-Script. It just works on one file yet.
|
||||||
|
#
|
||||||
|
# Just a litte Script that by default opens two instances of vlc.
|
||||||
|
#
|
||||||
|
# The first one will stream the passed files with the real time streaming
|
||||||
|
# protocol (rtsp) at $rtsspport. If the device $dev (e.g. 'eth0')
|
||||||
|
# has got a valid IPv4 address you can control the sever at
|
||||||
|
# {address of device}:$httpport. Note: localhost:$httpport will NOT work.
|
||||||
|
#
|
||||||
|
# If you do not wish this behaviour assign a false value to $httpport
|
||||||
|
# (my $httpport = 0; for example).
|
||||||
|
#
|
||||||
|
# You can control access to this webserver in the .hosts file
|
||||||
|
# (on ubuntu one can find this file in /usr/share/vlc/http).
|
||||||
|
#
|
||||||
|
# At the moment just one server instance will work.
|
||||||
|
#
|
||||||
|
# The second instance will indefinitely repeatedly listen on
|
||||||
|
# localhost:$rtspport and serves as the client, for local playback.
|
||||||
|
# If you do not wish local playblack assign a false value to
|
||||||
|
# $localplayback (my $localplayback = 0; for example);
|
||||||
|
#
|
||||||
|
# Todo:
|
||||||
|
# Check requirements first and die if they are not met.
|
||||||
|
# Implement a more versatile way of passing options to vlc.
|
||||||
|
# Support IPv6 by altering the regex.
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use v5.12;
|
||||||
|
|
||||||
|
#settings
|
||||||
|
my $dev = 'eth0'; #Your favourite interface here, maybe 'eth0';
|
||||||
|
my $httpport = 8080; #unsetting this will disable the webserver
|
||||||
|
my $rtspport = 5544;
|
||||||
|
my $localplayback = 1; #set to 0 if you do not wish local playback
|
||||||
|
#end settings
|
||||||
|
|
||||||
|
#if no arguments ar passed die
|
||||||
|
@ARGV > 0 or die "you forgot to pass some filenames to $0";
|
||||||
|
|
||||||
|
my $http = "";
|
||||||
|
|
||||||
|
#get ip addr of $dev
|
||||||
|
$_ = `ip addr show $dev`;
|
||||||
|
my ($address) = /inet ((\d\d?\.){3}\d\d?)/;
|
||||||
|
if ($address && $httpport) {
|
||||||
|
$http = "--extraintf http --http-host $address:$httpport ";
|
||||||
|
}
|
||||||
|
|
||||||
|
#escape arguments (samplemovie.avi to "samplemovie.avi");
|
||||||
|
@ARGV = map{ $_ = '"'.$_.'"' } @ARGV;
|
||||||
|
|
||||||
|
#start server
|
||||||
|
system "vlc @ARGV $http:sout=#rtp{sdp=rtsp://:$rtspport/} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep &";
|
||||||
|
|
||||||
|
#pause
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
#start client if applicable
|
||||||
|
system "vlc --repeat rtsp://localhost:$rtspport/" if $localplayback;
|
||||||
|
|
||||||
|
#ich mag Schokolade gern
|
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# #
|
||||||
|
# mbots mail routine #
|
||||||
|
# #
|
||||||
|
###############################
|
||||||
|
|
||||||
|
# ***** config section *****
|
||||||
|
#don't touch as long as you're not me. feel me?
|
||||||
|
version=".01"
|
||||||
|
author="david@socialnerds.org"
|
||||||
|
|
||||||
|
smtpserver="smtp.aec.at"
|
||||||
|
recipients="david@aec.at danielwe@aec.at geraldho@aec.at michaelgr@aec.at"
|
||||||
|
from="releasechecker@aec.at"
|
||||||
|
subject="ubuntu precise pangolin is out. download it. seed it."
|
||||||
|
line=$1
|
||||||
|
|
||||||
|
#if [ -f $line ]; then
|
||||||
|
# line=$(cat $line)
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# ***** start of script *****
|
||||||
|
|
||||||
|
#telnet connection
|
||||||
|
{
|
||||||
|
sleep 1
|
||||||
|
echo "HELO $HOSTNAME"
|
||||||
|
sleep 1
|
||||||
|
echo "MAIL FROM: $from"
|
||||||
|
sleep 1
|
||||||
|
for address in $recipients; do
|
||||||
|
echo "RCPT TO: $address"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo "DATA"
|
||||||
|
sleep 1
|
||||||
|
for address in $recipients; do
|
||||||
|
echo "To: $address"
|
||||||
|
done
|
||||||
|
echo "From: Release CheckeR <$from>"
|
||||||
|
echo "Subject: $subject"
|
||||||
|
sleep 1
|
||||||
|
echo "$line"
|
||||||
|
sleep 1
|
||||||
|
echo "."
|
||||||
|
sleep 1
|
||||||
|
echo "QUIT"
|
||||||
|
} | telnet $smtpserver 25
|
||||||
|
|
||||||
|
|
||||||
|
# ***** end of script *****
|
||||||
|
#live long and prosper
|
||||||
|
exit 0
|
Loading…
Reference in New Issue