File: conf_ban.py

package info (click to toggle)
pyftpd 0.8.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 524 kB
  • ctags: 448
  • sloc: python: 2,748; sh: 80; makefile: 43
file content (45 lines) | stat: -rwxr-xr-x 1,202 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python

banlist = []
banmsg = "You are banned"
try:
    from ban_config import *
except:
    pass

from Tkinter import *
import string, pprint, os, StringIO
import tkSimpleDialog, tkMessageBox, tkFileDialog, FileDialog

import TkinterConfigList

config_file = "ban_config.py"

class App(TkinterConfigList.App):

    def askval(self, initval="256.257.258.259"):
        "ask for the ip number"
        u = tkSimpleDialog.askstring("IP number", "IP number:", initialvalue=initval)
        if u == None:
            return None
        return u

    def opt(self):
        global banmsg
        r = tkSimpleDialog.askstring("banmsg", "Message for the banned ones:", initialvalue=banmsg)
        if r:
            banmsg = r

    def stringify(self, entry):
        return entry

    def prepare_for_save(self):
        stream = StringIO.StringIO()
        pprint.pprint(self.list, stream)
        s = stream.getvalue()
        stream.close()
        return "# list of banned ip's \nbanlist = "+s+"\n"+ \
                "banmsg = "+repr(banmsg)+"\n"

TkinterConfigList.go(Frame=App, title="configure banlist", list=banlist,
                default_config_file=config_file, hf="ban_README.txt")