imip-agent

Changeset

815:c64b593fa853
2015-10-07 Paul Boddie raw files shortlog changelog graph Added module path auto-configuration and a usage help string.
tools/make_freebusy.py (file)
     1.1 --- a/tools/make_freebusy.py	Wed Oct 07 17:40:11 2015 +0200
     1.2 +++ b/tools/make_freebusy.py	Wed Oct 07 17:42:29 2015 +0200
     1.3 @@ -21,6 +21,18 @@
     1.4  this program.  If not, see <http://www.gnu.org/licenses/>.
     1.5  """
     1.6  
     1.7 +from os.path import split
     1.8 +import sys
     1.9 +
    1.10 +# Find the modules.
    1.11 +
    1.12 +try:
    1.13 +    import imiptools
    1.14 +except ImportError:
    1.15 +    parent = split(split(__file__)[0])[0]
    1.16 +    if split(parent)[1] == "imip-agent":
    1.17 +        sys.path.append(parent)
    1.18 +
    1.19  from codecs import getwriter
    1.20  from imiptools.client import Client
    1.21  from imiptools.data import get_window_end, Object
    1.22 @@ -28,7 +40,6 @@
    1.23  from imiptools.period import insert_period
    1.24  from imiptools.profile import Preferences
    1.25  from imip_store import FileStore, FilePublisher
    1.26 -import sys
    1.27  
    1.28  def make_freebusy(store, publisher, preferences, user, participant,
    1.29      store_and_publish, include_needs_action, reset_updated_list, verbose):
    1.30 @@ -161,12 +172,14 @@
    1.31          user = participants[0]
    1.32      except IndexError:
    1.33          print >>sys.stderr, """\
    1.34 +Usage: %s <user> [ <other user> ] <options>
    1.35 +
    1.36  Need a user and an optional participant (if different from the user),
    1.37  along with the -s option if updating the store and the published details.
    1.38  Specify -n to include objects with PARTSTAT of NEEDS-ACTION.
    1.39  Specify -r to inspect all objects, not just those expected to provide details.
    1.40  Specify -v for additional messages on standard error.
    1.41 -    """
    1.42 +""" % split(sys.argv[0])[1]
    1.43          sys.exit(1)
    1.44  
    1.45      # Define any other participant of interest plus options.