Comments (11)
Sure, depending on it being in PATH is probably better, and way more portable.
(And yes, that's where it appears on Debian).
from txtorcon.
The path to tor's default executable could be put into a variable in txtorcon.torconfig; this might become handy for logging when using local tor-builds from git etc.
Consider
# Try to find tor
try:
proc = subprocess.Popen(('type', '-p', 'tor'), stdout=subprocess.PIPE)
out, _ = proc.communicate()
TOR_BINARY = os.abspath(out)
except:
TOR_BINARY = 'tor'
def launch_tor(tor_binary=None, *args):
if tor_binary is None:
tor_binary = torconfig.TOR_BINARY
log.info('Executing tor as "%s"' % (tor_binary, ))
from txtorcon.
Yes, sounds good.
Do we want to export this via init as "txtorcon.TOR_BINARY"? (Actually, it might be better to just document that we'll use the "tor" in your PATH, and if you want to do crazier things you can always specify it to launch_tor).
from txtorcon.
The advantage of the stub above would be to have fully qualified pathnames in every reference to the tor binary used by txtorcon. Consider logs referring to '/home/user/tor_git/bin/tor' instead of '/usr/bin/tor' both for pasting and self-assurance.
We can document that txtorcon tries to locate tor via 'type' (which consults PATH among other things) and falls back to just 'tor', leaving it to the shell.
The code should probably live in txtorcon/init.py
from txtorcon.
On MacOS, tor will not get executed just as 'tor'. The twisted documentation states regarding reactor.spawnProcess()
executable is the full path of the program to run
So we should use os.abspath like above
from txtorcon.
sold.
use fully-qualified paths always.
from txtorcon.
I've committed some changes to my master branch. The new find_tor_binary()-function will search for the binary using the shell first; if that fails, it consults some default installation paths in case tor is not on PATH (which it usually is not on MacOS).
A new exception TorNotFound is raised in launch_tor() if the supplied/found tor-binary does not exists or is not executable by the current user. I thought this fail-fast behaviour to be of advance as we get a catchable exception before trashing the reactor.
Also, should this function now really live in init.py ?
from txtorcon.
I don't really know where to put this; no particular thought went into which file it's in now. I'd like to avoid putting "real" code in init, just because I find it weird -- but of course some standard libraries do that, so...
from txtorcon.
Did I miss a pull-request for this?
from txtorcon.
No. The code in init.py
rubs me in the wrong way; I'll move it into utils.py and provide some silly unittest.
Notice that the documentation for build_tor_connection has to be updated and build_local_tor_connection does not have one yet.
from txtorcon.
closed by recent pull cd26505
from txtorcon.
Related Issues (20)
- attribute-error on python 3.9
- All of test.test_util is skipped HOT 1
- All of test.test_web skipped
- Many tests in test.test_endpoints.EndpointTests fail when calling `_tor_launcher` with incompatible arguments
- Hosting onion service log says .onion twice
- Three tests errors (test_attribute_access, test_other_bootstrap, and ProtocolIntegrationTests.test_with_arg) HOT 3
- v2 onion in repo metadata HOT 1
- update CI
- use unittest.mock instead of mock HOT 3
- Unable to install txsocksx with python 3 HOT 1
- There is a lingering ipaddress dependency declaration HOT 1
- 1 test fails: AttributeError: [...] does not have the attribute 'pwd'
- twisted.web Agent created by txtorcon should accept other Agent options
- Add support for Python 3.10 and 3.11
- Three unit tests are failing on Python 3.12
- When tor process exits unexpectedly tor.protocol.get_info hangs HOT 5
- Handle limits better HOT 1
- debian sid bug: 1060955
- cant gpg verefy 23.11.0 HOT 6
- Drop or declare dependency on six HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from txtorcon.