Example #1
0
 def Validate(self, value, key=None):
   """Validates a schedule."""
   if value is None:
     raise validation.MissingAttribute('schedule must be specified')
   if not isinstance(value, basestring):
     raise TypeError('schedule must be a string, not \'%r\''%type(value))
   try:
     groctimespecification.GrocTimeSpecification(value)
   except groc.GrocException, e:
     raise validation.ValidationError('schedule \'%s\' failed to parse: %s'%(
         value, e.args[0]))
Example #2
0
 def Validate(self, value, key=None):
   """Validates a schedule."""
   if value is None:
     raise validation.MissingAttribute('schedule must be specified')
   if not isinstance(value, six_subset.string_types):
     raise TypeError('schedule must be a string, not \'%r\''%type(value))
   # If we're running on py3 and don't have access to groctimespecification,
   # then the server will still do the validation on the schedule property.
   if groc and groctimespecification:
     try:
       groctimespecification.GrocTimeSpecification(value)
     except groc.GrocException as e:
       raise validation.ValidationError('schedule \'%s\' failed to parse: %s'%(
           value, e.args[0]))
   return value
Example #3
0
 def _ValidateCronEntry(self, cron):
     # TODO(user): consider timezone validation, not currently done by the
     # Java SDK.
     if not cron.url:
         return 'No URL for <cron> entry'
     if not cron.schedule:
         return "No schedule provided for <cron> entry with URL '%s'" % cron.url
     # If we're running on py3 and don't have access to groctimespecification,
     # then the server will still do the validation on the schedule property.
     if groc and groctimespecification:
         try:
             groctimespecification.GrocTimeSpecification(cron.schedule)
         except groc.GrocException:
             return ("Text '%s' in <schedule> node failed to parse,"
                     ' for <cron> entry with url %s.' %
                     (cron.schedule, cron.url))