Initialize the paths used by the application.
(self)
| 387 | if manager is not None: |
| 388 | networks_dir = getattr(manager, 'networks_dir', None) |
| 389 | default_ssid = getattr(manager, 'default_ssid', None) |
| 390 | slugify = getattr(manager, '_slugify', None) |
| 391 | if callable(slugify) and default_ssid is not None: |
| 392 | try: |
| 393 | default_slug = slugify(default_ssid) |
| 394 | except Exception: |
| 395 | default_slug = 'default' |
| 396 | |
| 397 | if not networks_dir: |
| 398 | networks_dir = os.path.join(self.datadir, 'networks') |
| 399 | |
| 400 | logger.debug(f"SCANNED_NETWORKS: Calculating using directory {networks_dir}, default_slug={default_slug}") |
| 401 | |
| 402 | try: |
| 403 | entries = os.listdir(networks_dir) |
| 404 | except OSError as exc: |
| 405 | logger.warning(f"SCANNED_NETWORKS: Unable to read {networks_dir}: {exc}") |
| 406 | return 0 |
| 407 | |
| 408 | count = 0 |
| 409 | for entry in entries: |
| 410 | if entry.startswith('.'): |
| 411 | continue |
| 412 | path = os.path.join(networks_dir, entry) |
| 413 | if not os.path.isdir(path): |
| 414 | continue |
| 415 | if entry in (default_slug, 'default'): |
| 416 | continue |
| 417 | count += 1 |
| 418 | |
| 419 | logger.info(f"SCANNED_NETWORKS: Calculated count {count} (excluding {default_slug})") |
| 420 | return count |
| 421 | |
| 422 | def initialize_paths(self): |
| 423 | """Initialize the paths used by the application.""" |
| 424 | """Folders paths""" |
| 425 | self.currentdir = os.path.dirname(os.path.abspath(__file__)) |
| 426 | # Directories directly under currentdir |
| 427 | self.configdir = os.path.join(self.currentdir, 'config') |
| 428 | self.datadir = os.path.join(self.currentdir, 'data') |
| 429 | self.actions_dir = os.path.join(self.currentdir, 'actions') |
| 430 | self.webdir = os.path.join(self.currentdir, 'web') |
| 431 | self.resourcesdir = os.path.join(self.currentdir, 'resources') |
| 432 | self.backupbasedir = os.path.join(self.currentdir, 'backup') |
| 433 | # Directories under backupbasedir |
| 434 | self.backupdir = os.path.join(self.backupbasedir, 'backups') |
| 435 | self.upload_dir = os.path.join(self.backupbasedir, 'uploads') |
| 436 | |
| 437 | # Directories under datadir |
| 438 | self.logsdir = os.path.join(self.datadir, 'logs') |
| 439 | self.output_dir = os.path.join(self.datadir, 'output') |
| 440 | self.input_dir = os.path.join(self.datadir, 'input') |
| 441 | # Directories under output_dir |
| 442 | self._default_crackedpwddir = os.path.join(self.output_dir, 'crackedpwd') |
| 443 | self._default_datastolendir = os.path.join(self.output_dir, 'data_stolen') |
| 444 | self.crackedpwddir = self._default_crackedpwddir |
| 445 | self.datastolendir = self._default_datastolendir |
| 446 | self.zombiesdir = os.path.join(self.output_dir, 'zombies') |
no test coverage detected