Transport Errors

- The 'push' and 'pull' commands now properly distinguish between a missing
  transport utility and other errors (thanks to Russell Steicke).
This commit is contained in:
Paul Beckingham 2013-03-03 09:34:54 -05:00
parent 1428a4135b
commit c978b2b65a
11 changed files with 98 additions and 93 deletions

View file

@ -82,6 +82,7 @@ The following submitted code, packages or analysis, and deserve special thanks:
Vincent Petithory Vincent Petithory
Rainer Müller Rainer Müller
Jakub Wilk Jakub Wilk
Russell Steicke
Thanks to the following, who submitted detailed bug reports and excellent Thanks to the following, who submitted detailed bug reports and excellent
suggestions: suggestions:

View file

@ -35,6 +35,8 @@ Features
+ Fixed the mechanism used for selecting translations (thanks to Fidel Mato). + Fixed the mechanism used for selecting translations (thanks to Fidel Mato).
+ Added new export script: export-tsv.pl. + Added new export script: export-tsv.pl.
+ Added the configuration variable 'print.empty.columns'. + Added the configuration variable 'print.empty.columns'.
+ The 'push' and 'pull' commands now properly distinguish between a missing
transport utility and other errors (thanks to Russell Steicke).
Bugs Bugs
+ Fixed bug #642, so that the default 'data.location=~/.task' preserves the + Fixed bug #642, so that the default 'data.location=~/.task' preserves the

1
NEWS
View file

@ -11,6 +11,7 @@ New Features in taskwarrior 2.2.0
- The 'columns' command now supports search term for the column name. - The 'columns' command now supports search term for the column name.
- New date shortcuts, 'socm' and 'eocm', meaning start and end of current - New date shortcuts, 'socm' and 'eocm', meaning start and end of current
month. month.
- Improved error messages for 'push' and 'pull' transport problems.
New commands in taskwarrior 2.2.0 New commands in taskwarrior 2.2.0

View file

@ -93,7 +93,8 @@ int Transport::execute()
} }
int result = ::execute (_executable, _arguments); int result = ::execute (_executable, _arguments);
int err; int err;
switch (result) { switch (result)
{
case 127: case 127:
throw format (STRING_TRANSPORT_NORUN, _executable); throw format (STRING_TRANSPORT_NORUN, _executable);
case -1: case -1:

View file

@ -35,7 +35,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TransportCurl::TransportCurl(const Uri& uri) : Transport(uri) TransportCurl::TransportCurl(const Uri& uri) : Transport(uri)
{ {
_executable = "curl"; _executable = "curl";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -34,68 +34,68 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TransportRSYNC::TransportRSYNC(const Uri& uri) : Transport(uri) TransportRSYNC::TransportRSYNC(const Uri& uri) : Transport(uri)
{ {
_executable = "rsync"; _executable = "rsync";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportRSYNC::send(const std::string& source) void TransportRSYNC::send(const std::string& source)
{ {
if (_uri._host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_RSYNC_URI); throw std::string (STRING_TRANSPORT_RSYNC_URI);
// Is there more than one file to transfer? // Is there more than one file to transfer?
// Then path has to end with a '/' // Then path has to end with a '/'
if (is_filelist(source) && !_uri.is_directory()) if (is_filelist(source) && !_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, _uri._path); throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
// cmd line is: rsync [--port=PORT] source [user@]host::path // cmd line is: rsync [--port=PORT] source [user@]host::path
if (_uri._port != "") if (_uri._port != "")
{ {
_arguments.push_back ("--port=" + _uri._port); _arguments.push_back ("--port=" + _uri._port);
} }
_arguments.push_back (source); _arguments.push_back (source);
if (_uri._user != "") if (_uri._user != "")
{ {
_arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path); _arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path);
} }
else else
{ {
_arguments.push_back (_uri._host + "::" + _uri._path); _arguments.push_back (_uri._host + "::" + _uri._path);
} }
if (execute ()) if (execute ())
throw std::string (STRING_TRANSPORT_RSYNC_FAIL); throw std::string (STRING_TRANSPORT_RSYNC_FAIL);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportRSYNC::recv(std::string target) void TransportRSYNC::recv(std::string target)
{ {
if (_uri._host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_RSYNC_URI); throw std::string (STRING_TRANSPORT_RSYNC_URI);
// Is there more than one file to transfer? // Is there more than one file to transfer?
// Then target has to end with a '/' // Then target has to end with a '/'
if (is_filelist(_uri._path) && !is_directory(target)) if (is_filelist(_uri._path) && !is_directory(target))
throw format (STRING_TRANSPORT_URI_NODIR, target); throw format (STRING_TRANSPORT_URI_NODIR, target);
// cmd line is: rsync [--port=PORT] [user@]host::path target // cmd line is: rsync [--port=PORT] [user@]host::path target
if (_uri._port != "") if (_uri._port != "")
_arguments.push_back ("--port=" + _uri._port); _arguments.push_back ("--port=" + _uri._port);
if (_uri._user != "") if (_uri._user != "")
{ {
_arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path); _arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path);
} }
else else
{ {
_arguments.push_back (_uri._host + "::" + _uri._path); _arguments.push_back (_uri._host + "::" + _uri._path);
} }
_arguments.push_back (target); _arguments.push_back (target);
if (execute ()) if (execute ())
throw std::string (STRING_TRANSPORT_RSYNC_FAIL); throw std::string (STRING_TRANSPORT_RSYNC_FAIL);
} }

View file

@ -35,73 +35,73 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TransportSSH::TransportSSH(const Uri& uri) : Transport(uri) TransportSSH::TransportSSH(const Uri& uri) : Transport(uri)
{ {
_executable = "scp"; _executable = "scp";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportSSH::send(const std::string& source) void TransportSSH::send(const std::string& source)
{ {
if (_uri._host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_SSH_URI); throw std::string (STRING_TRANSPORT_SSH_URI);
// Is there more than one file to transfer? // Is there more than one file to transfer?
// Then path has to end with a '/' // Then path has to end with a '/'
if (is_filelist(source) && !_uri.is_directory()) if (is_filelist(source) && !_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, _uri._path); throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
// cmd line is: scp [-p port] [user@]host:path // cmd line is: scp [-p port] [user@]host:path
if (_uri._port != "") if (_uri._port != "")
{ {
_arguments.push_back ("-P"); _arguments.push_back ("-P");
_arguments.push_back (_uri._port); _arguments.push_back (_uri._port);
} }
_arguments.push_back (source); _arguments.push_back (source);
if (_uri._user != "") if (_uri._user != "")
{ {
_arguments.push_back (_uri._user + "@" + _uri._host + ":" + escape (_uri._path, ' ')); _arguments.push_back (_uri._user + "@" + _uri._host + ":" + escape (_uri._path, ' '));
} }
else else
{ {
_arguments.push_back (_uri._host + ":" + escape (_uri._path, ' ')); _arguments.push_back (_uri._host + ":" + escape (_uri._path, ' '));
} }
if (execute ()) if (execute ())
throw std::string (STRING_TRANSPORT_SSH_FAIL); throw std::string (STRING_TRANSPORT_SSH_FAIL);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportSSH::recv(std::string target) void TransportSSH::recv(std::string target)
{ {
if (_uri._host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_SSH_URI); throw std::string (STRING_TRANSPORT_SSH_URI);
// Is there more than one file to transfer? // Is there more than one file to transfer?
// Then target has to end with a '/' // Then target has to end with a '/'
if (is_filelist(_uri._path) && !is_directory(target)) if (is_filelist(_uri._path) && !is_directory(target))
throw format (STRING_TRANSPORT_URI_NODIR, target); throw format (STRING_TRANSPORT_URI_NODIR, target);
// cmd line is: scp [-p port] [user@]host:path // cmd line is: scp [-p port] [user@]host:path
if (_uri._port != "") if (_uri._port != "")
{ {
_arguments.push_back ("-P"); _arguments.push_back ("-P");
_arguments.push_back (_uri._port); _arguments.push_back (_uri._port);
} }
if (_uri._user != "") if (_uri._user != "")
{ {
_arguments.push_back (_uri._user + "@" + _uri._host + ":" + escape (_uri._path, ' ')); _arguments.push_back (_uri._user + "@" + _uri._host + ":" + escape (_uri._path, ' '));
} }
else else
{ {
_arguments.push_back (_uri._host + ":" + escape (_uri._path, ' ')); _arguments.push_back (_uri._host + ":" + escape (_uri._path, ' '));
} }
_arguments.push_back (target); _arguments.push_back (target);
if (execute ()) if (execute ())
throw std::string (STRING_TRANSPORT_SSH_FAIL); throw std::string (STRING_TRANSPORT_SSH_FAIL);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -838,7 +838,7 @@
// Transport // Transport
#define STRING_TRANSPORT_NORUN "Could not run '{1}'. Is it installed, and available in $PATH?" #define STRING_TRANSPORT_NORUN "Could not run '{1}'. Is it installed, and available in $PATH?"
#define STRING_TRANSPORT_NOFORK "Could not run '{1}': {2}. Are you out of system resources?" #define STRING_TRANSPORT_NOFORK "Could not run '{1}': {2}. Are you out of system resources?"
#define STRING_TRANSPORT_URI_NODIR "The uri '{1}' does not appear to be a directory." #define STRING_TRANSPORT_URI_NODIR "The uri '{1}' does not appear to be a directory."
#define STRING_TRANSPORT_CURL_URI "When using the 'curl' protocol, the uri must contain a hostname." #define STRING_TRANSPORT_CURL_URI "When using the 'curl' protocol, the uri must contain a hostname."
#define STRING_TRANSPORT_CURL_WILDCD "When using the 'curl' protocol, wildcards are not supported." #define STRING_TRANSPORT_CURL_WILDCD "When using the 'curl' protocol, wildcards are not supported."

View file

@ -853,16 +853,16 @@
#define STRING_TEXT_AMBIGUOUS "Ambiguo {1} '{2}' - puede ser " #define STRING_TEXT_AMBIGUOUS "Ambiguo {1} '{2}' - puede ser "
// Transport // Transport
#define STRING_TRANSPORT_NORUN "Could not run '{1}'. Is it installed, and available in $PATH?" #define STRING_TRANSPORT_NORUN "No se pudo lanzar '{1}'. ¿Está instalado y disponible en $PATH?"
#define STRING_TRANSPORT_NOFORK "Could not run '{1}': {2}. Are you out of system resources?" #define STRING_TRANSPORT_NOFORK "Could not run '{1}': {2}. Are you out of system resources?"
#define STRING_TRANSPORT_URI_NODIR "El uri '{1}' no parece ser un directorio." #define STRING_TRANSPORT_URI_NODIR "El uri '{1}' no parece ser un directorio."
#define STRING_TRANSPORT_CURL_URI "Cuando se usa el protocolo 'curl' el uri debe contener un nombre de máquina." #define STRING_TRANSPORT_CURL_URI "Cuando se usa el protocolo 'curl' el uri debe contener un nombre de máquina."
#define STRING_TRANSPORT_CURL_WILDCD "Cuando se usa el protocolo 'curl' no están soportados los comodines." #define STRING_TRANSPORT_CURL_WILDCD "Cuando se usa el protocolo 'curl' no están soportados los comodines."
#define STRING_TRANSPORT_CURL_FAIL "Curl falló, consulte los mensajes precedentes." #define STRING_TRANSPORT_CURL_FAIL "Curl falló, consulte los mensajes precedentes."
#define STRING_TRANSPORT_RSYNC_URI "Cuando se usa el protocolo 'rsync' el uri debe contener un nombre de máquina." #define STRING_TRANSPORT_RSYNC_URI "Cuando se usa el protocolo 'rsync' el uri debe contener un nombre de máquina."
#define STRING_TRANSPORT_RSYNC_FAIL "rsync failed, see output above." #define STRING_TRANSPORT_RSYNC_FAIL "Rsync falló, consulte los mensajes precedentes."
#define STRING_TRANSPORT_SSH_URI "Cuando se usa el protocolo 'ssh' el uri debe contener un nombre de máquina." #define STRING_TRANSPORT_SSH_URI "Cuando se usa el protocolo 'ssh' el uri debe contener un nombre de máquina."
#define STRING_TRANSPORT_SSH_FAIL "ssh failed, see output above." #define STRING_TRANSPORT_SSH_FAIL "Ssh falló, consulte los mensajes precedentes."
// Uri // Uri
#define STRING_URI_QUOTES "No se pudo interpretar el uri '{1}', uso erróneo de comillas simples." #define STRING_URI_QUOTES "No se pudo interpretar el uri '{1}', uso erróneo de comillas simples."

View file

@ -427,7 +427,7 @@ int execute(const std::string& executable, std::vector<std::string> arguments)
char** argv = new char*[4]; char** argv = new char*[4];
argv[0] = shell; // sh argv[0] = shell; // sh
argv[1] = opt; // -c argv[1] = opt; // -c
argv[2] = (char*)cmdline.c_str(); // e.g. scp undo.data user@host:.task/ argv[2] = (char*)cmdline.c_str(); // e.g. scp undo.data user@host:.task/
argv[3] = NULL; // required by execv argv[3] = NULL; // required by execv
int ret = execvp(shell, argv); int ret = execvp(shell, argv);

View file

@ -41,12 +41,12 @@ if (open my $fh, '>', 'bug.rc')
# Bug 668: URL should allow users with dot character # Bug 668: URL should allow users with dot character
my $output = qx{../src/task rc:bug.rc merge user.name\@taskwarrior.org:undo.data 2>&1}; my $output = qx{../src/task rc:bug.rc merge user.name\@taskwarrior.org:undo.data 2>&1};
like ($output, qr/^Could not run ssh. Is it installed, and available in \$PATH\?$/m, 'ssh does not connect'); like ($output, qr/ssh failed/, 'ssh does not connect');
unlike ($output, qr/not a valid modifier/, 'scp syntax with dots'); unlike ($output, qr/not a valid modifier/, 'scp syntax with dots');
unlike ($output, qr/not in the expected format/, 'scp syntax with dots'); unlike ($output, qr/not in the expected format/, 'scp syntax with dots');
$output = qx{../src/task rc:bug.rc merge ssh://user.name\@taskwarrior.org/undo.data 2>&1}; $output = qx{../src/task rc:bug.rc merge ssh://user.name\@taskwarrior.org/undo.data 2>&1};
like ($output, qr/^Could not run ssh. Is it installed, and available in \$PATH\?$/m, 'ssh does not connect'); like ($output, qr/ssh failed/, 'ssh does not connect');
unlike ($output, qr/not a valid modifier/, 'standard syntax with dots'); unlike ($output, qr/not a valid modifier/, 'standard syntax with dots');
unlike ($output, qr/not in the expected format/, 'standard syntax with dots'); unlike ($output, qr/not in the expected format/, 'standard syntax with dots');