How to use _spawn_daemon method in pyatom

Best Python code snippet using pyatom_python

daemon_spawner_tests.py

Source:daemon_spawner_tests.py Github

copy

Full Screen

...75 file_path = os.path.join(temp_dir, IDB_PID_PATH)76 with open(file_path, "w") as file:77 json.dump([1, 2], file)78 self.assertEqual([1, 2], _get_pids())79 async def test_spawn_daemon(self) -> None:80 await self.spawn_daemon(on_darwin=False)81 async def test_spawn_daemon_darwin(self) -> None:82 await self.spawn_daemon(on_darwin=True)83 async def spawn_daemon(self, on_darwin: bool) -> None:84 _clear_saved_pids()85 with tempfile.TemporaryDirectory() as temp_dir:86 self.spawner._log_file_path = mock.Mock(return_value=temp_dir + "/daemon")87 self.spawner._read_daemon_output = AsyncMock()88 with mock.patch(89 "idb.client.daemon_spawner.asyncio.create_subprocess_exec",90 new=AsyncMock(),91 ) as exec_mock, mock.patch(92 "idb.client.daemon_spawner.platform.system",93 new=mock.Mock(return_value="Darwin" if on_darwin else "NotDarwin"),94 ), mock.patch(95 "idb.client.daemon_spawner.sys.argv", new=["idb_path"]96 ):97 exec_mock.return_value.pid = 12398 await self.spawner._spawn_daemon()99 exec_mock.assert_called_once_with(100 "idb_path",101 "daemon",102 *(["--notifier-path", "idb_companion"] if on_darwin else []),103 stdout=asyncio.subprocess.PIPE,104 stderr=mock.ANY,105 )106 self.assertEqual(_get_pids(), [123])107 async def test_read_daemon_output_json(self) -> None:108 stream = mock.Mock()109 stream.readline = AsyncMock(return_value=json.dumps({}).encode("utf-8"))110 await self.spawner._read_daemon_output(stream)111 async def test_read_daemon_output_garbage(self) -> None:112 stream = mock.Mock()...

Full Screen

Full Screen

client.py

Source:client.py Github

copy

Full Screen

...15import pickle16import subprocess17from mypass import Error, DaemonFailed, ConnectionLost, SOCKET18from mypass.config import get_config19def _spawn_daemon(passphrase):20 process = subprocess.Popen(21 [sys.executable, '-m', 'mypass.daemon'],22 env=dict(os.environ, LD_PRELOAD=(os.environ.get('LD_PRELOAD', '') +23 ' libsqlcipher.so.0').lstrip()),24 stdin=subprocess.PIPE,25 stdout=subprocess.PIPE26 )27 with process.stdout:28 with process.stdin:29 process.stdin.write(passphrase.encode('utf-8'))30 process.stdout.read()31 if process.poll() is not None:32 raise DaemonFailed33class Client:34 def __init__(self):35 try:36 self._connect()37 except (FileNotFoundError, ConnectionRefusedError):38 self._file = None39 def __enter__(self):40 return self41 def __exit__(self, exc_type, exc_value, traceback):42 self.close()43 def _connect(self):44 with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:45 sock.connect(SOCKET)46 self._file = sock.makefile('rwb', 0)47 @property48 def database_locked(self):49 return not self._file50 def unlock_database(self, passphrase):51 _spawn_daemon(passphrase)52 self._connect()53 def call(self, command, *args):54 try:55 pickle.dump((command, args), self._file)56 output = pickle.load(self._file)57 except (BrokenPipeError, EOFError):58 raise ConnectionLost59 if isinstance(output, Error):60 raise output61 return output62 def close(self):63 if self._file:64 self._file.close()65def database_exists():...

Full Screen

Full Screen

offlineimap-daemon.py

Source:offlineimap-daemon.py Github

copy

Full Screen

...20 self.run_ev.clear()21 if self.run_daemon:22 self.is_running = True23 print('offlineimap is being started')24 self._spawn_daemon()25 print('offlineimap has stopped')26 self.run_ev.set() # check state and restart if needed27 def _spawn_daemon(self):28 self.daemon_proc = subprocess.Popen(['offlineimap', '-u', 'basic'], shell=False)29 self.daemon_proc.wait()30 self.daemon_proc = None31 def start(self):32 print('starting offlineimap')33 self.run_daemon = True34 self.run_ev.set()35 def stop(self):36 print('stopping offlineimap')37 self.run_daemon = False38 if self.daemon_proc:39 try:40 self.daemon_proc.send_signal(signal.SIGUSR2)41 except OSError:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful