File: conf_fs_chroot.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 (49 lines) | stat: -rwxr-xr-x 1,353 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
46
47
48
49
#!/usr/bin/python

from utils import isdir, defaultdir
chrootlist = []
try:
    from fs_chroot_config import *
except:
    pass

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

import TkinterConfigList

config_file = "fs_chroot_config.py"

class App(TkinterConfigList.App):

    def askval(self, initval=("anonymous", defaultdir)):
        "ask for the user and path"
        u = tkSimpleDialog.askstring("username", "username", initialvalue=initval[0])
        if u == None:
            return None
        pd = FileDialog.FileDialog(master=self.frame, title="Chroot directory")
        path = pd.go(dir_or_file=initval[1])
        if path == None:
            return None
        if os.path.exists(path) and not isdir(path):
            path = os.path.dirname(path)
        return u, path


    def stringify(self, tup):
        return tup[0]+" : "+tup[1]

    def prepare_for_save(self):
        stream = StringIO.StringIO()
        pprint.pprint(self.list, stream)
        s = stream.getvalue()
        stream.close()
        return """
        slave_fs = "%s"
        chrootlist = %s
        """ % (slavefs, s)
        

TkinterConfigList.go(Frame=App, title="configure fs_chroot", list=chrootlist,
                default_config_file=config_file, hf="fs_chroot_README.txt")