diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 15:38:29 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 15:38:29 +0000 |
commit | 7de8b1873902cb8857a27ae6b0b6d5b5291d62b0 (patch) | |
tree | 78c19a6307e0bee6eb8a2cda8fc99b6bcc373072 | |
parent | e5366896e9ccb3dd17c590d115bd999e987a33af (diff) | |
download | chromium_src-7de8b1873902cb8857a27ae6b0b6d5b5291d62b0.zip chromium_src-7de8b1873902cb8857a27ae6b0b6d5b5291d62b0.tar.gz chromium_src-7de8b1873902cb8857a27ae6b0b6d5b5291d62b0.tar.bz2 |
Get scripts working independent of where they are run.
Also store script data in home directory.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/2832019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50598 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | remoting/host/simple_host_process.cc | 16 | ||||
-rwxr-xr-x | remoting/tools/gettoken.py | 6 | ||||
-rwxr-xr-x | remoting/tools/register_host.py | 6 | ||||
-rwxr-xr-x | remoting/tools/runclient.py | 20 |
4 files changed, 35 insertions, 13 deletions
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index 5ed70e0..09f6a96 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -14,6 +14,7 @@ #include <iostream> #include <string> +#include <stdlib.h> #include "build/build_config.h" @@ -21,6 +22,7 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/logging.h" +#include "base/scoped_nsautorelease_pool.h" #include "base/thread.h" #include "base/waitable_event.h" #include "remoting/host/capturer_fake.h" @@ -40,15 +42,22 @@ #endif #if defined(OS_WIN) -const std::wstring kDefaultConfigPath = L"ChromotingConfig.json"; +const std::wstring kDefaultConfigPath = L".ChromotingConfig.json"; +const wchar_t kHomePath[] = L"HOMEPATH"; +const wchar_t* GetEnvironmentVar(const wchar_t* x) { return _wgetenv(x); } #else -const std::string kDefaultConfigPath = "ChromotingConfig.json"; +static char* GetEnvironmentVar(const char* x) { return getenv(x); } +const char kHomePath[] = "HOME"; +const std::string kDefaultConfigPath = ".ChromotingConfig.json"; #endif const std::string kFakeSwitchName = "fake"; const std::string kConfigSwitchName = "config"; int main(int argc, char** argv) { + // Needed for the Mac, so we don't leak objects when threads are created. + base::ScopedNSAutoreleasePool pool; + CommandLine::Init(argc, argv); const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); @@ -72,7 +81,8 @@ int main(int argc, char** argv) { // Check the argument to see if we should use a fake capturer and encoder. bool fake = cmd_line->HasSwitch(kFakeSwitchName); - FilePath config_path(kDefaultConfigPath); + FilePath config_path(GetEnvironmentVar(kHomePath)); + config_path = config_path.Append(kDefaultConfigPath); if (cmd_line->HasSwitch(kConfigSwitchName)) { config_path = cmd_line->GetSwitchValuePath(kConfigSwitchName); } diff --git a/remoting/tools/gettoken.py b/remoting/tools/gettoken.py index 3a61927..a4024d7 100755 --- a/remoting/tools/gettoken.py +++ b/remoting/tools/gettoken.py @@ -13,7 +13,7 @@ import urllib import gaia_auth -auth_filename = '.chromotingAuthToken' +auth_filepath = os.path.join(os.getenv('HOME'), '.chromotingAuthToken') print "Email:", email = raw_input() @@ -25,7 +25,7 @@ auth_token = authenticator.authenticate(email, passwd) # Set permission mask for created file. os.umask(0066) -auth_file = open(auth_filename, 'w') +auth_file = open(auth_filepath, 'w') auth_file.write(email) auth_file.write('\n') auth_file.write(auth_token) @@ -35,4 +35,4 @@ print print 'Auth token:' print print auth_token -print '...saved in', auth_filename +print '...saved in', auth_filepath diff --git a/remoting/tools/register_host.py b/remoting/tools/register_host.py index bb9f473..11e5e4c 100755 --- a/remoting/tools/register_host.py +++ b/remoting/tools/register_host.py @@ -19,7 +19,7 @@ import gaia_auth server = 'www-googleapis-test.sandbox.google.com' url = 'http://' + server + '/chromoting/v1/@me/hosts' -settings_filename = 'ChromotingConfig.json' +settings_filepath = os.path.join(os.getenv('HOME'), '.ChromotingConfig.json') print "Email:", email = raw_input() @@ -70,7 +70,7 @@ auth_token = authenticator.authenticate(email, password) # Write settings file. os.umask(0066) # Set permission mask for created file. -settings_file = open(settings_filename, 'w') +settings_file = open(settings_filepath, 'w') settings_file.write('{\n'); settings_file.write(' "xmpp_login" : "' + email + '",\n') settings_file.write(' "xmpp_auth_token" : "' + auth_token + '",\n') @@ -80,4 +80,4 @@ settings_file.write(' "public_key" : "' + public_key + '"\n') settings_file.write('}\n') settings_file.close() -print 'Configuration saved in', settings_filename +print 'Configuration saved in', settings_filepath diff --git a/remoting/tools/runclient.py b/remoting/tools/runclient.py index 62db605..000b70e 100755 --- a/remoting/tools/runclient.py +++ b/remoting/tools/runclient.py @@ -9,11 +9,24 @@ # so that the host authentication arguments can be automatically set. import os +import platform -auth_filename = '.chromotingAuthToken' +auth_filepath = os.path.join(os.getenv('HOME'), '.chromotingAuthToken') +script_path = os.path.dirname(__file__) + +if platform.system() == "Windows": + # TODO(garykac): Make this work on Windows. + print 'Not yet supported on Windows.' + exit(1) +elif platform.system() == "Darwin": # Darwin == MacOSX + client_path = '../../xcodebuild/Debug/chromoting_simple_client' +else: + client_path = '../../out/Debug/chromoting_x11_client' + +client_path = os.path.join(script_path, client_path) # Read username and auth token from token file. -auth = open(auth_filename) +auth = open(auth_filepath) authinfo = auth.readlines() username = authinfo[0].rstrip() @@ -26,9 +39,8 @@ print 'Host JID:', username + '/chromoting', hostjid_suffix = raw_input() hostjid = username + '/chromoting' + hostjid_suffix -# TODO(garykac): Make this work on Windows. command = [] -command.append('../../out/Debug/chromoting_x11_client') +command.append(client_path) command.append('--host_jid ' + hostjid) command.append('--jid ' + username) command.append('--token ' + authtoken) |