Esempio n. 1
0
    def get(self):
        """GET request; takes path as an argument."""
        path = self.get_path()
        base = util.get_base_path_adjustment()

        files = []
        try:
            file_list = os.listdir(os.path.join(base, path))
            for i in file_list:
                try:
                    filename = os.path.join(base, path, i)
                    is_file = os.path.isfile(filename)
                    confirm = ''
                    if is_file and os.path.getsize(filename) > 10485760:
                        confirm = 'large'
                    if is_file and not util.is_text_file(filename):
                        confirm = 'binary'
                    files.append({
                        'name': i,
                        'is_file': is_file,
                        'confirm': confirm
                    })
                except IOError as error:
                    log.warn(error)
        except Exception as error:  # pylint: disable=W0703
            log.warn(error)

        self.do_output(files, base)
Esempio n. 2
0
 def get(self):
     """GET request; takes an argument path as the full path to the folder
     to be created.
     """
     try:
         path = self.get_path()
         os.mkdir(os.path.join(util.get_base_path_adjustment(), path))
         self.do_success()
     except:  # pylint: disable=W0702
         self.do_failure()
Esempio n. 3
0
 def get(self):
     """GET request; takes an argument path as the full path to the folder
     to be created.
     """
     try:
         path = self.get_path()
         os.mkdir(os.path.join(
             util.get_base_path_adjustment(),
             path
         ))
         self.do_success()
     except:  # pylint: disable=W0702
         self.do_failure()
Esempio n. 4
0
    def get(self):
        """GET request; takes an argument file as the full path of the file to
        download.
        """
        filename = self.get_file()
        basename = util.find_base(filename)

        try:
            full_path = os.path.join(util.get_base_path_adjustment(), filename)
            file_handler = open(full_path, "rb")
            data = file_handler.read()
            file_handler.close()
            length = os.path.getsize(full_path)
        except Exception as error:  # pylint: disable=W0703
            log.error(error)
            data = None
            length = 0

        self.do_headers(basename, length)
        self.finish(data)
Esempio n. 5
0
    def get(self):
        """GET request; takes an argument file as the full path of the file to
        load into the editor.
        """
        filename = self.get_file()
        full_filename = os.path.join(util.get_base_path_adjustment(), filename)
        text = ""
        saved = False
        read_only = util.get_configuration_value("readOnly", False)
        if not read_only and os.path.exists(full_filename):
            read_only = not os.access(full_filename, os.W_OK)

        try:
            file_handler = open(full_filename, "r")
            text = file_handler.read()
            file_handler.close()
            saved = True
        except Exception as error:  # pylint: disable=W0703
            log.warn(error)

        self.do_output(text, saved=saved, read_only=read_only)
Esempio n. 6
0
    def get(self):
        """GET request; takes arguments file and text for the path of the file
        to save and the content to put in it.
        """
        try:
            filename = self.get_file()
            full_filename = os.path.join(util.get_base_path_adjustment(), filename)
            read_only = util.get_configuration_value("readOnly", False)
            if not read_only and (not os.path.exists(full_filename) or os.access(full_filename, os.W_OK)):
                text = self.get_text()
                file_handler = open(full_filename, "w")
                file_handler.write(text)
                file_handler.close()

                self.broadcast_save(filename)
                self.do_success()
            else:
                self.do_failure()
        except Exception as error:  # pylint: disable=W0703
            log.error(error)
            self.do_failure()
Esempio n. 7
0
    def get(self):
        """GET request; takes an argument file as the full path of the file to
        download.
        """
        filename = self.get_file()
        basename = util.find_base(filename)

        try:
            full_path = os.path.join(
                util.get_base_path_adjustment(),
                filename
            )
            file_handler = open(full_path, 'rb')
            data = file_handler.read()
            file_handler.close()
            length = os.path.getsize(full_path)
        except Exception as error:  # pylint: disable=W0703
            log.error(error)
            data = None
            length = 0

        self.do_headers(basename, length)
        self.finish(data)
Esempio n. 8
0
    def get(self):
        """GET request; takes an argument file as the full path of the file to
        load into the editor.
        """
        filename = self.get_file()
        full_filename = os.path.join(
            util.get_base_path_adjustment(),
            filename
        )
        text = ''
        saved = False
        read_only = util.get_configuration_value('readOnly', False)
        if not read_only and os.path.exists(full_filename):
            read_only = not os.access(full_filename, os.W_OK)

        try:
            file_handler = open(full_filename, 'r')
            text = file_handler.read()
            file_handler.close()
            saved = True
        except Exception as error:  # pylint: disable=W0703
            log.warn(error)

        self.do_output(text, saved = saved, read_only = read_only)
Esempio n. 9
0
    def get(self):
        """GET request; takes arguments file and text for the path of the file
        to save and the content to put in it.
        """
        try:
            filename = self.get_file()
            full_filename = os.path.join(
                util.get_base_path_adjustment(),
                filename
            )
            read_only = util.get_configuration_value('readOnly', False)
            if not read_only and (not os.path.exists(full_filename) or os.access(full_filename, os.W_OK)):
                text = self.get_text()
                file_handler = open(full_filename, 'w')
                file_handler.write(text)
                file_handler.close()

                self.broadcast_save(filename)
                self.do_success()
            else:
                self.do_failure()
        except Exception as error:  # pylint: disable=W0703
            log.error(error)
            self.do_failure()
Esempio n. 10
0
    def get(self):
        """GET request; takes path as an argument."""
        path = self.get_path()
        base = util.get_base_path_adjustment()

        files = []
        try:
            file_list = os.listdir(os.path.join(base, path))
            for i in file_list:
                try:
                    filename = os.path.join(base, path, i)
                    is_file = os.path.isfile(filename)
                    confirm = ""
                    if is_file and os.path.getsize(filename) > 10485760:
                        confirm = "large"
                    if is_file and not util.is_text_file(filename):
                        confirm = "binary"
                    files.append({"name": i, "is_file": is_file, "confirm": confirm})
                except IOError as error:
                    log.warn(error)
        except Exception as error:  # pylint: disable=W0703
            log.warn(error)

        self.do_output(files, base)