Пример #1
0
 def __init__(self,
              fp=None,
              headers=None,
              outerboundary="",
              environ=os.environ,
              keep_blank_values=0,
              strict_parsing=0):
     self.environ = environ
     FieldStorage.__init__(self, fp, headers, outerboundary, environ,
                           keep_blank_values, strict_parsing)
Пример #2
0
    def __init__(self, filename, content=None, datafile=None):
        if not content and not datafile:
            raise ValueError('At least one of content or datafile should be defined')

        if content and datafile:
            raise ValueError('Either content or datafile should be defined')

        env = dict()
        env['REQUEST_METHOD'] = 'DUMMY'

        FieldStorage.__init__(self, fp=StringIO(content) if content else datafile, environ=env)
        # FieldStorage is declared as an old-style class, so super() cannot be used
        #super(MockFieldStorage, self).__init__(fp=StringIO(content))
        self.filename = filename
Пример #3
0
    def __init__(self,
                 req,
                 headers=None,
                 outerboundary=b'',
                 environ={},
                 keep_blank_values=0,
                 strict_parsing=0,
                 limit=None,
                 encoding='utf-8',
                 errors='replace',
                 file_callback=None):
        """Constructor of FieldStorage.

        Many of input parameters are need only for next internal use, because
            FieldStorage parse variables recursive. You need add only:
                req             - Request object.
                keep_blank_values - if you want to parse blank values as right
                                 empty values.
                strict_parsing  - if you want to raise exception on parsing
                                 error.
                file_callback   - callback for creating instance of uploading
                                 files.
        """

        if isinstance(req, Request):
            if req.environ.get('wsgi.input', None) is None:
                raise ValueError('No wsgi input File in request environment.')

            environ = {'REQUEST_METHOD': 'POST'}
            if 'CONTENT_TYPE' in req.environ:
                environ['CONTENT_TYPE'] = req.environ['CONTENT_TYPE']
            if 'CONTENT_LENGTH' in req.environ:
                environ['CONTENT_LENGTH'] = req.environ['CONTENT_LENGTH']
            if file_callback:
                environ['wsgi.file_callback'] = file_callback

            headers = req.headers_in
            req = req.environ.get('wsgi.input')

        self.environ = environ
        if version_info[0] < 3:
            CgiFieldStorage.__init__(self, req, headers, outerboundary,
                                     environ, keep_blank_values,
                                     strict_parsing)
        else:
            CgiFieldStorage.__init__(self, req, headers, outerboundary,
                                     environ, keep_blank_values,
                                     strict_parsing, limit, encoding, errors)
Пример #4
0
 def __init__(self, conf, version):
     FieldStorage.__init__(self)
     self.conf = conf
     self.version = version
     self.interfaces = [
         'eth0',
         'eth1',
         'eth2',
         'eth0-eth2',
         'eth3',
         'wlan0',
         'wlan1',
     ]
     ip = ''
     for interface in self.interfaces:
         try:
             ip = get_ip_address(interface)
             if ip:
                 self.ip = ip
             break
         except:
             self.ip = 'localhost'
     if 'url' in self.conf['infos']:
         self.url = 'http://' + self.conf['infos']['url']
     else:
         self.url = 'http://' + self.ip
     self.rss_url = self.url + '/rss/telecaster.xml'
     self.port = '8000'
     self.acpi = acpi.Acpi()
     self.format = self.conf['media']['format']
     self.short_name = self.conf['infos']['short_name']
     self.title = self.conf['infos']['name'] + ' - ' + self.conf['infos'][
         'description']
     self.departments = self.conf['department']
     self.professors = self.conf['professor']
     self.professors.sort()
     self.comments = self.conf['comment']
     self.len_departments = len(self.departments)
     self.len_professors = len(self.professors)
     self.conference_nb_max = 40
     self.professor_nb_max = 40
     self.refresh = False
     self.refresh_value = 20
     self.uid = os.getuid()
     self.casting = False
     self.writing = False
Пример #5
0
    def __init__(self, req, headers=None, outerboundary=b'', environ={},
                 keep_blank_values=0, strict_parsing=0, limit=None,
                 encoding='utf-8', errors='replace', file_callback=None):
        """Constructor of FieldStorage.

        Many of input parameters are need only for next internal use, because
            FieldStorage parse variables recursive. You need add only:
                req             - Request object.
                keep_blank_values - if you want to parse blank values as right
                                 empty values.
                strict_parsing  - if you want to raise exception on parsing
                                 error.
                file_callback   - callback for creating instance of uploading
                                 files.
        """

        if isinstance(req, Request):
            if req.environ.get('wsgi.input', None) is None:
                raise ValueError('No wsgi input File in request environment.')

            environ = {'REQUEST_METHOD': 'POST'}
            if 'CONTENT_TYPE' in req.environ:
                environ['CONTENT_TYPE'] = req.environ['CONTENT_TYPE']
            if 'CONTENT_LENGTH' in req.environ:
                environ['CONTENT_LENGTH'] = req.environ['CONTENT_LENGTH']
            if file_callback:
                environ['wsgi.file_callback'] = file_callback

            headers = req.headers_in
            req = req.environ.get('wsgi.input')

        self.environ = environ
        if version_info[0] < 3:
            CgiFieldStorage.__init__(self, req, headers, outerboundary,
                                     environ, keep_blank_values,
                                     strict_parsing)
        else:
            CgiFieldStorage.__init__(self, req, headers, outerboundary,
                                     environ, keep_blank_values,
                                     strict_parsing, limit, encoding, errors)
Пример #6
0
 def __init__(self, conf, version):
     FieldStorage.__init__(self)
     self.conf = conf
     self.version = version
     self.interfaces = ["eth0", "eth1", "eth2", "eth0-eth2", "eth3", "wlan0", "wlan1"]
     ip = ""
     for interface in self.interfaces:
         try:
             ip = get_ip_address(interface)
             if ip:
                 self.ip = ip
             break
         except:
             self.ip = "localhost"
     if "url" in self.conf["infos"]:
         self.url = "http://" + self.conf["infos"]["url"]
     else:
         self.url = "http://" + self.ip
     self.rss_url = self.url + "/rss/telecaster.xml"
     self.port = "8000"
     self.acpi = acpi.Acpi()
     self.format = self.conf["media"]["format"]
     self.short_name = self.conf["infos"]["short_name"]
     self.title = self.conf["infos"]["name"] + " - " + self.conf["infos"]["description"]
     self.departments = self.conf["department"]
     self.professors = self.conf["professor"]
     self.professors.sort()
     self.comments = self.conf["comment"]
     self.len_departments = len(self.departments)
     self.len_professors = len(self.professors)
     self.conference_nb_max = 40
     self.professor_nb_max = 40
     self.refresh = False
     self.refresh_value = 20
     self.uid = os.getuid()
     self.casting = False
     self.writing = False
Пример #7
0
 def __init__(self, *args, **kw):
   self._ok_max_files_count=-1
   FieldStorage.__init__(self, *args, **kw)
Пример #8
0
 def __init__ (self, fp=None, headers=None, outerboundary="",
               environ=os.environ, keep_blank_values=0, strict_parsing=0):
     self.environ = environ
     FieldStorage.__init__ (self, fp, headers, outerboundary,
                            environ, keep_blank_values, strict_parsing)
Пример #9
0
 def __init__(self, *args, **kw):
   self._ok_max_files_count=-1
   FieldStorage.__init__(self, *args, **kw)