MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / create_users_storage_directory

Function create_users_storage_directory

web/pgadmin/utils/paths.py:144–178  ·  view source on GitHub ↗

This function is used to iterate through all the users and create users directory if not already created.

()

Source from the content-addressed store, hash-verified

142
143
144def create_users_storage_directory():
145 """
146 This function is used to iterate through all the users and
147 create users directory if not already created.
148 """
149 # Don't move this import statement to the top of the file,
150 # it throws circular import error.
151 import config
152 if not config.SERVER_MODE:
153 return None
154
155 users = User.query.all()
156
157 for usr in users:
158 username = preprocess_username(usr.username)
159
160 storage_dir = getattr(
161 config, 'STORAGE_DIR',
162 os.path.join(
163 os.path.realpath(
164 os.path.expanduser(PGADMIN_PATH)
165 ), 'storage'
166 )
167 )
168
169 if storage_dir is None:
170 return None
171
172 storage_dir = os.path.join(
173 storage_dir.decode('utf-8') if hasattr(storage_dir, 'decode')
174 else storage_dir, username
175 )
176
177 if not os.path.exists(storage_dir):
178 os.makedirs(storage_dir, int('700', 8))

Callers 1

create_userFunction · 0.90

Calls 4

preprocess_usernameFunction · 0.85
joinMethod · 0.80
decodeMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected