コード例 #1
0
ファイル: DatabasePlugin.py プロジェクト: freenas/middleware
    def run(self, fd):
        result = []
        for i in self.datastore.collection_list():
            result.append(dump_collection(self.datastore, i))

        with os.fdopen(fd.fd, mode='w', closefd=False) as f:
            dump(result, f)
コード例 #2
0
    def run(self, fd):
        result = []
        for i in self.datastore.collection_list():
            result.append(dump_collection(self.datastore, i))

        with os.fdopen(fd.fd, mode='w', closefd=False) as f:
            dump(result, f)
コード例 #3
0
ファイル: DatabasePlugin.py プロジェクト: erinix/middleware
    def run(self, fd):
        result = []
        for i in self.datastore.collection_list():
            result.append(dump_collection(self.datastore, i))

        try:
            with os.fdopen(fd.fd, mode='w', closefd=False) as f:
                dump(result, f)
        except OSError as err:
            raise TaskException(err.errno, err.strerror)
コード例 #4
0
ファイル: DatabasePlugin.py プロジェクト: surajrav/middleware
    def run(self, fd):
        result = []
        for i in self.datastore.collection_list():
            result.append(dump_collection(self.datastore, i))

        try:
            with os.fdopen(fd.fd, mode='w', closefd=False) as f:
                dump(result, f)
        except OSError as err:
            raise TaskException(err.errno, err.strerror)
コード例 #5
0
ファイル: FlatFilePlugin.py プロジェクト: surajrav/middleware
    def change_password(self, username, password):
        try:
            with open(self.passwd_filename, 'r') as f:
                passwd = load(f)

            user = first_or_default(lambda u: u['username'] == username, passwd)
            if not user:
                raise OSError(errno.ENOENT, os.strerror(errno.ENOENT))

            user.update({
                'unixhash': crypted_password(password),
                'smbhash': nt_password(password),
                'password_changed_at': datetime.datetime.utcnow()
            })

            with open(self.passwd_filename + '.tmp', 'w') as f:
                dump(passwd, f, indent=4)

            os.rename(self.passwd_filename + '.tmp', self.passwd_filename)
            shutil.copy(self.passwd_filename, os.path.join('/conf/base', self.passwd_filename[1:]))
            self.__load()
        except (IOError, ValueError) as err:
            logger.warn('Cannot change password: {0}'.format(str(err)))
            raise