MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / read_data

Method read_data

shared.py:1869–1926  ·  view source on GitHub ↗

Read data from SQLite database. Returns data in the same format as CSV for backward compatibility.

(self)

Source from the content-addressed store, hash-verified

1867 logger.error(f"Error updating image randomizer: {e}")
1868 self.imagegen = None
1869
1870 def wrap_text(self, text, font, max_width):
1871 """Wrap text to fit within a specified width when rendered.
1872 On Pager, this is monkey-patched by PagerRagnar.setup_pager_shared_data()
1873 to use character-based wrapping instead of PIL fonts."""
1874 if font is None or ImageFont is None:
1875 # Fallback: character-based wrapping (no PIL)
1876 lines = []
1877 for line in text.split('\n'):
1878 while len(line) > 40:
1879 lines.append(line[:40])
1880 line = line[40:]
1881 lines.append(line)
1882 return lines
1883 try:
1884 lines = []
1885 words = text.split()
1886 while words:
1887 line = ''
1888 while words and font.getlength(line + words[0]) <= max_width:
1889 line = line + (words.pop(0) + ' ')
1890 lines.append(line)
1891 return lines
1892 except Exception as e:
1893 logger.error(f"Error wrapping text: {e}")
1894 raise
1895
1896
1897 def _slug_for_ssid(self, ssid):
1898 if self.storage_manager is not None and hasattr(self.storage_manager, '_slugify'):
1899 try:
1900 return self.storage_manager._slugify(ssid)
1901 except Exception:
1902 return self.storage_manager.default_ssid
1903 if self.storage_manager is not None:
1904 return (ssid or self.storage_manager.default_ssid or 'default')
1905 return ssid or 'default'
1906
1907 # ── Subnet scan log helpers ──────────────────────────────────
1908 def append_subnet_scan_log(self, cidr, status, message, devices=None):
1909 """Append an entry to the subnet scan log visible in the UI.
1910
1911 Args:
1912 cidr: The subnet that was scanned (or 'primary').
1913 status: 'ok' | 'error' | 'info' | 'skip'
1914 message: Human-readable description.
1915 devices: Number of devices found (optional).
1916 """
1917 import datetime as _dt
1918 entry = {
1919 'ts': _dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
1920 'cidr': str(cidr),
1921 'status': status,
1922 'msg': message,
1923 }
1924 if devices is not None:
1925 entry['devices'] = int(devices)
1926 with self._subnet_scan_log_lock:

Callers 15

execute_manual_attackMethod · 0.80
get_verbose_debug_logsFunction · 0.80
runMethod · 0.80
__init__Method · 0.80
load_scan_fileMethod · 0.80
ftp_connector.pyFile · 0.80
__init__Method · 0.80
load_scan_fileMethod · 0.80
load_scan_fileMethod · 0.80

Calls 5

get_all_hostsMethod · 0.80
debugMethod · 0.80
appendMethod · 0.80
errorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected