This function is used to iterate through all the users and create users directory if not already created.
()
| 142 | |
| 143 | |
| 144 | def 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)) |
no test coverage detected