Esempio n. 1
0
    def form_addTime(self, data):
        acls = []

        for ip, i in self.sysconf.ProxyConfig.get('srcacls', []):
            acls.append((i,i))

        for n, i in self.sysconf.ProxyConfig.get('aclusers', []):
            acls.append((i,i))

        for n, i in self.sysconf.ProxyConfig.get('domacls', []):
            acls.append((i,i))

        form = formal.Form(self.submitTime)[        
            formal.Field('allow', formal.Boolean(), label = "Allow",
                description = "Allow traffic at these times"),
            formal.Field('from', formal.Time(required=True), label = "From time", 
                description = "Starting time (24 hour format)"),
            formal.Field('to', formal.Time(required=True), label = "To time", 
                description = "Ending time (24 hour format), must be later than the starting time and must not overlap midnight"),

            formal.Field('domain', formal.String(), label = "Domain", 
                description = "Apply this rule to a specific domain"), 

            formal.Field('exacl', formal.String(), formal.widgetFactory(formal.SelectChoice, options = acls), label = "Extra ACL", 
                description = "Apply this rule to a specific other ACL"),
            
            formal.Group('Days')[
                [ formal.Field(i, formal.Boolean(), label = i) for i in PageHelpers.days ]
            ]
        ]
        form.data['from'] = datetime.time(0,0)
        form.data['to'] = datetime.time(23,59)
        form.addAction(self.submitTime)
        return form
Esempio n. 2
0
 def testTime(self):
     self.assertEquals(formal.Time().validate(None), None)
     self.assertEquals(formal.Time().validate(time(12, 30, 30)),
                       time(12, 30, 30))
     self.assertEquals(
         formal.Time(missing=time(12, 30, 30)).validate(None),
         time(12, 30, 30))
     self.assertEquals(
         formal.Time(missing=time(12, 30, 30)).validate(time(12, 30, 31)),
         time(12, 30, 31))
     self.assertRaises(formal.FieldValidationError,
                       formal.Time(required=True).validate, None)
Esempio n. 3
0
 def form_example(self, ctx):
     form = formal.Form()
     form.addField('aString', formal.String())
     form.addField('aTime', formal.Time())
     form.addAction(self.submitted)
     form.data = {
         'aTime': datetime.utcnow().time(),
     }
     return form
Esempio n. 4
0
 def form_example(self, ctx):
     form = formal.Form()
     form.addField('isoFormatDate', formal.Date(), formal.TextInput)
     form.addField('datePartsSelect', formal.Date(), formal.widgetFactory(formal.DatePartsSelect, dayFirst=True))
     form.addField('monthFirstDate', formal.Date(), formal.DatePartsInput)
     form.addField('dayFirstDate', formal.Date(), formal.widgetFactory(formal.DatePartsInput, dayFirst=True))
     form.addField('monthYearDate', formal.Date(), formal.MMYYDatePartsInput)
     form.addField('twoCharYearDate', formal.Date(), formal.widgetFactory(formal.DatePartsInput, twoCharCutoffYear=70))
     form.addField('time', formal.Time())
     form.addAction(self.submitted)
     return form
Esempio n. 5
0
 def form_example(self, ctx):
     form = formal.Form()
     form.addField('aString', formal.String())
     form.addField('aInteger', formal.Integer())
     form.addField('aFloat', formal.Float())
     if haveDecimal:
         form.addField('aDecimal', formal.Decimal())
     form.addField('aBoolean', formal.Boolean())
     form.addField('aDate', formal.Date())
     form.addField('aTime', formal.Time())
     form.addAction(self.submitted)
     return form
Esempio n. 6
0
def createForm(self, form):
    AvailLetters = findDisks()

    form.addField('desc', formal.String(required=False), label = "Description")
    form.addField('fileset', formal.String(required=True), label = "Source Path(s)", description = "Paths to backup, separated by a comma.")
    form.addField('exclude', formal.String(required=False), label = "Exclude", 
            description = "List of patterns to exclude from backup (eg: *.mp3, *.avi), seperated by comma")
    form.addField('mailto', formal.String(required=False), label = "Notifications", 
            description = "Email address(es) to be notified once backup has been completed, separated by comma")
    form.addField('dest', formal.String(required=True), label = "Destination", 
            description = "Destination directory.")

    form.addField('config', formal.Boolean(), label = "Configuration", 
        description = "Include system configuration in backup")

    form.data['dest'] = 'backup'

    form.addField('type', formal.String(required=True),
        formal.widgetFactory(formal.SelectChoice, options = [
                ('usb', 'USB'), 
                ('smb', 'Windows Share'), 
                ('path', 'Local path')
        ]
    ), label = "Backup Type")

    #Local path
    form.addField('pathPath', formal.String(), label = "Destination Path")

    #USB fields
    form.addField('usbDev', formal.String(),
            formal.widgetFactory(formal.SelectChoice, options = AvailLetters), label = "USB Device")

    if AvailLetters:
        form.data['usbDev'] = AvailLetters[0][0]

    #SMB fields
    form.addField('smbHost', formal.String(required=True), label = "Remote Host", description = "Server where file share is hosted.")
    form.data['smbHost'] = 'server'
    form.addField('smbShare', formal.String(required=True), label = "Share", description = "Name of share on server.")
    form.data['smbShare'] = 'public'
    form.addField('smbUser', formal.String(), label = "Username")
    form.addField('smbPass', formal.String(), label = "Password")

    form.addField('time', formal.Time(), label = "Scheduled Time", 
        description = "The time to run the backup if scheduled.")
Esempio n. 7
0
    def form_addBackup(self, data):
        form = formal.Form()
        try:
            storageNodes = os.listdir('/proc/scsi/usb-storage/')
        except:
            storageNodes = []
        AvailLetters = []
        usbStorage = {}
        for s in storageNodes:
            l = open('/proc/scsi/usb-storage/%s' % s)
            for i in l:
                ln = i.strip()
                if "Vendor" in ln:
                    vendor = ln.split(':')[-1].strip()
                if "Serial Number" in ln:
                    sn = ln.split(':')[-1].strip().split()[0]

            usbStorage[sn] = vendor
            AvailLetters.append((sn, vendor))

        form.addField('descrip', formal.String(), label = self.text.backupHeaderDescription)

        form.addField('backpath', formal.String(required=True), label = self.text.backupPath, 
            description = self.text.backupPathDescription)

        form.addField('destpath', formal.String(required=True), label = self.text.backupDestination,
            description = self.text.backupDestinationDescription)

        form.addField('notify', formal.String(), label = self.text.backupNotify, 
            description = self.text.backupNotifyDescription)
            
        form.addField('backupdrive', formal.String(required=True),
            formal.widgetFactory(formal.SelectChoice, options = AvailLetters), label = self.text.backupDrive)

        form.addField('sched', formal.Boolean(), label = self.text.backupSchedule)
        form.addField('time', formal.Time(), label = self.text.backupTime)

        if AvailLetters: 
            form.data['backupdrive']  = AvailLetters[0]
        form.data['destpath'] = "backup"

        form.addAction(self.submitForm)
        return form