Commit graph

13 commits

Author SHA1 Message Date
Chen Congwu
b5138faee1 syncevo-phone-config: some syntax fixes 2010-04-28 08:06:57 +02:00
Patrick Ohly
b2bd8ff35d syncevo-phone-config: fix combined calendar detection for Nokia phones?! (MBC #1197)
After thinking some more about this, I think the current version of
the script will fail to detect combined calendar+todo for Nokias,
because of the changed order of URIs that we test. I think Nokia
phones ignore the URI that we send to it and then decides on the data
store entirely based on the data type. That way the first URIs for
calendar and todo are accepted ("Calendar" and "Task"), which breaks
the "URI equal" comparison.

The fix should be simple - test the calendar URIs first when testing
todos, as it was done before my last commit.
2010-04-28 08:06:57 +02:00
Patrick Ohly
07e74b9996 syncevo-phone-config: reimplemented template generation and calendar+todo detection (MBC #1197)
--combined-calendar-task was broken: because "calendar+todo" was
tested with only an event, the test always passed when using the
settings for events, even if tasks cannot be exchanged using those
settings. If it had worked and had been essential to get correct
results, the option should have been enabled by default.

The new implementation of combined calendar+todo storage works
differently, without increasing the number of tests that need to
be run when searching for complete settings:
- detect settings for "calendar" using VEVENT as test data
- detect settings for "todo" using VTODO as test data
- if uri identical, configure a "calendar+todo" source instead of
  separate "calendar" and "todo"

Note that this hasn't been tested yet.

The --combined-calendar-task option is thus obsolete and was removed.

The template generation was rewritten and now prints the template
to stdout. While doing this, some more changes were made:
- "type" is always set, even if using default data formats,
  because "default" data formats are a bit underspecified and it
  is better to be explicit about what worked
- previously, "type" did not distinguish between events and tasks
  because it omitted the "calendar:" and "todo:" type part
- the template is printed if and only if --advanced is enabled,
  because only then is the result reliable; disabling it makes
  little sense when printing to stdout, so --create-template was
  removed

The generated config is no longer derived from the 'Nokia 7210c'
template. Instead the "SyncEvolution Client" template is used, because
it does not contain a potentially unused "calendar+todo" source.
The same fix for missing "calendar/todo" in "type" also had to
be applied to to the created config.

The syncevo-phone-config tool used source names that differed from the
syncevolution command line, for example "contact" was used instead of
"addressbook". This was not only making the code more complex (it had
two different ways to map "contact" to "addressbook"), it was also
exposed to users via the --source option. Now the same
addressbook/calendar/memo/todo names as in the rest of the
SyncEvolution command line are used.

This patch also includes quite a bit of code, language and output
cleanup. The code still isn't as pythonic as it could be, though.
2010-04-28 08:06:57 +02:00
Patrick Ohly
ea3fafe99c syncevo-phone-config: let CTRL-C really abort syncevolution (MBC #1197)
The signal handler in syncevolution interpret CTRL-C as suspend
request. When invoked by syncevo-phone-config, that is not what is
intended by the user and usually had the effect that a sync session
failed without flagging the abort request, thus keeping the script
running.

This patch adds SYNCEVOLUTION_NO_SYNC_SIGNALS, which prevents
installing the signal handlers, and uses that in the script.
As a result, CTRL-C leads to "aborted prematurely", for which
a test was added earlier.

Because syncevolution has to do no cleanup work, aborting it
like this is okay.
2010-04-28 08:06:57 +02:00
Patrick Ohly
f0af60b6a8 syncevo-phone-config: use -v for minimal information about tested config, -v -v for full output (MBC #1197)
It was hard to tell what was being tested. Previously one only had
the choice between very verbose debugging output and minimal
progress information.

This patch turns -v into a counter that can be repeated on the command
line. -v now adds the config to the progress message, still using one
line per test. -v -v is the complete debug output.
2010-04-28 08:06:57 +02:00
Patrick Ohly
92a7d791be syncevo-phone-config: avoid writing in user's .config while testing (MBC #1197)
Using a fixed, unique config name and a @test-phone context was meant
to avoid conflicts with user data, but that still has drawbacks:
- extra clean up code necessary
- cannot run multiple syncevo-phone-config calls in parallel

A better solution is to set XDG_CONFIG_HOME to the temporary directory.
That way we can leave the last test config in place, for review by the
user or a developer.

Another advantage is that it is safe to run without daemon mode, because
there really isn't any overlap left with the normal sync system. Not
using daemon mode
- has less overhead (no D-Bus involved)
- is easier to debug
- does not interfer with other, normal sync sessions

The patch renames the "syncevo" variable to ensure that all references
to it were updated. "syncevoCmd" is also a bit easier to search for.
2010-04-28 08:06:57 +02:00
Patrick Ohly
1ece0e2109 syncevo-phone-config: avoid deprecated popen2, check for fatal status (MBC #1197)
Invoking "find" via popen2 is not particularly efficient. It also
triggers deprecation warnings. Better use native Python facilities,
like file pattern matching via glob. This is also shorter.

Instead of using an ad-hoc parser for the file, better use ConfigParser.
Some utility class is needed to massage our file content into shape
for it, because ConfigParser expects sections, which we don't write.

While we are at it, also check for premature exit of syncevolution.
The most likely reason for that is "killall -9 syncevolution", which
is currently the most reliable way to kill it because CTRL-C is not
always checked (needs to be fixed, though). Another reason are
fatal bugs in the binary, which should also abort testing.
2010-04-28 08:06:57 +02:00
Patrick Ohly
3ccdc3c97b syncevo-phone-config: fixed mkdir (MBC #1197)
A mkdir invocation failed because of a missing -p parameter.
Not sure whether creating the directory was really necessary,
but when the script does it, it should at least do it right.

This patch also switches to native Python functions instead of
invoking the "rm" and "mkdir" shell commands.
2010-04-28 08:06:57 +02:00
Patrick Ohly
79fbb7f683 syncevo-phone-config: do not hide command line errors (MBC #1197)
In non-verbose mode, 2>/dev/null hid errors, including errors
caused by the script itself which need to be fixed (like a missing
"-p" for mkdir). Better show errors in all cases. Because syncevolution
itself prints to stdout, this does not produce more output in
non-verbose mode either.
2010-04-28 08:06:56 +02:00
Patrick Ohly
83abbb96b1 syncevo-phone-config: fixed Python syntax errors
First, the "tempfile" variable clashed with the global tempfile module
and later was expected to be called "testfile". "tmpdir" is a better
description, because it is not the name of a file.

Second, the testConfig and testResult variables must explicitly
set as global variables. Variable assignments are local by default
in Python. Declaring the variables first is not strictly necessary,
but done to be consistent with other global variables.
2010-04-28 08:06:56 +02:00
Chen Congwu
6549757434 phone-config-tool: setting test data and test result temp dir (MB#9862) 2010-04-20 09:27:06 +02:00
Chen Congwu
6e69e6a129 config-phone: interrupt handling 2010-04-19 11:35:40 +02:00
Chen Congwu
1022e21494 Test tools: automatically detection working configuration for a phone (MB#9862)
This is a python script that tries with all possible configuration
combinations for a phone, once found the corresponding configuration and
the configuration template can be generated.
The script is installed as 'syncevo-phone-config'
2010-04-19 11:35:40 +02:00