GithubHelp home page GithubHelp logo

Comments (11)

meejah avatar meejah commented on May 31, 2024

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.

lukaslueg avatar lukaslueg commented on May 31, 2024

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.

meejah avatar meejah commented on May 31, 2024

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.

lukaslueg avatar lukaslueg commented on May 31, 2024

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.

lukaslueg avatar lukaslueg commented on May 31, 2024

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.

meejah avatar meejah commented on May 31, 2024

sold.
use fully-qualified paths always.

from txtorcon.

lukaslueg avatar lukaslueg commented on May 31, 2024

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.

meejah avatar meejah commented on May 31, 2024

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.

meejah avatar meejah commented on May 31, 2024

Did I miss a pull-request for this?

from txtorcon.

lukaslueg avatar lukaslueg commented on May 31, 2024

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.

lukaslueg avatar lukaslueg commented on May 31, 2024

closed by recent pull cd26505

from txtorcon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.