diff --git a/bin/ws_find b/bin/ws_find index 3106efb..16072f4 100755 --- a/bin/ws_find +++ b/bin/ws_find @@ -35,7 +35,7 @@ from __future__ import print_function -import os, os.path, pwd, grp, sys +import os, os.path, pwd, grp, sys, yaml from optparse import OptionParser @@ -55,8 +55,6 @@ def read_python_conf(): read_python_conf() -import yaml - # who are we? uid = os.getuid() gid = os.getgid() @@ -89,7 +87,7 @@ if options.filesystem: if options.filesystem in config["workspaces"]: filesystems = [options.filesystem] else: - print("Error: no such filesystem.") + print("Error: no such filesystem.", file=sys.stderr) sys.exit(-1) else: filesystems = config["workspaces"].keys() @@ -121,10 +119,12 @@ if options.list: print(i) sys.exit(0) +# Print usage, if no argument provided if len(args) == 0: print(usage, file=sys.stderr) sys.exit(-1) +# Retrieve ws name as first argument wsname = args[0] # main loop diff --git a/bin/ws_register b/bin/ws_register index 8fc023b..2cfd1a8 100755 --- a/bin/ws_register +++ b/bin/ws_register @@ -40,7 +40,7 @@ from __future__ import print_function import os, os.path, pwd, grp, sys -import glob +import glob, yaml import argparse import pathlib @@ -61,9 +61,6 @@ def read_python_conf(): read_python_conf() -import yaml - - # who are we? uid = os.getuid() username = pwd.getpwuid(uid).pw_name diff --git a/bin/ws_send_ical b/bin/ws_send_ical index 952ca37..5b6981c 100755 --- a/bin/ws_send_ical +++ b/bin/ws_send_ical @@ -7,8 +7,8 @@ python version of ws_send_ical command, no privileges necessary - send a rminder as VCALENDAR entry for a named workspace to the - address. + send a reminder as VCALENDAR entry for a named workspace to the + address. Reads new YAML configuration files and new YAML workspace database. @@ -43,6 +43,7 @@ from __future__ import print_function import os, os.path, pwd, grp, sys import glob, time from optparse import OptionParser +import getpass ### from datetime import datetime, date, time import smtplib @@ -174,7 +175,9 @@ def send_ical(entry, smtphost, resource, attendee, mail_from, login, ws_name, cr # so we have to determine user and read config first, and parse commandline last # who are we? -login = os.getlogin() +# https://bugs.python.org/issue32651 +login = getpass.getuser() +# login = os.getlogin() create_time = time.strftime("%Y%m%dT%H%M00", time.localtime(None)) uid = os.getuid() gid = os.getgid() diff --git a/ws.conf_full_sample b/ws.conf_full_sample index 282c22f..85c8028 100644 --- a/ws.conf_full_sample +++ b/ws.conf_full_sample @@ -1,39 +1,38 @@ # this file illustrates and documents the workspace++ config files -# this is a YAML file, view with tabstop=8 # use ws_validate_config to validate a config file -clustername: aName # mandantory, a name to identify the system -smtphost: localhosti # mandantory, a host accepting smtp connections to send emails -mail_from: noreply@mydomain.de # sender address for reminders -default: lustre # mandantory, the default workspace to choose -duration: 10 # mantantory, the max duration in days, if not specified in workspace -durationdefault: 1 # optional, if user does not give duration, this will be used -reminderdefault: 0 # optional, if set, users will always get mail, in doubt local mail to username -maxextensions: 1 # mandantory, the number of extensions, if not specified in workspace -pythonpath: /path/to/my/python # optional, path which is appended to python search path for ws_list and other pythons scripts to find yaml -dbuid: 9999 # mandantory -dbgid: 9999 # mandantory -admins: [hobel] # list of admin users, for ws_list -deldir_timeout: 3600 # maximum time in secs to delete a single workspace. -workspaces: # now the list of the workspaces - lustre: # name of workspace as shown with ws_list -l - keeptime: 1 # mandantory, time in days to keep workspaces after they expired - spaces: [/lustre1/ws, /lustre2/ws] # mandantory, list of directories - spaceselection: random # "random" (default), "uid" (uid%#spaces), "gid" (gid%#spaces) - deleted: .removed # mandantory, will be appended to spaces and database - # to move deleted files to - database: /lustre-db # mandantory, the DB directory, this is where DB files will end - duration: 30 # max duration, overwrites global value - groupdefault: [inst1,inst2] # users of those groups will have this workspace as default - userdefault: [user1] # those users will have this workspace as default - user_acl: [user1] # as soon as user_acl or group_acl exist, - # the workspace is access restricted to those users/groups listed - group_acl: [adm] - maxextensions: 5 # maximum extensios allowed - allocatable: no # do not allow new allocations in this workspace if no - extendable: no # do not allow extensions in this workspace if no - restorable: no # do not allow restores from this workspace if no - nfs: # second workspace, minimum example - keeptime: 1 # mandantory, time in days to keep workspaces after they expired - database: /nfs-db - spaces: [/nfs1/ws] - deleted: .trash +clustername: aName # mandatory, a name to identify the system +smtphost: localhosti # mandatory, a host accepting smtp connections to send emails +mail_from: noreply@mydomain.de # sender address for reminders +default: lustre # mandatory, the default workspace to choose +duration: 10 # mandatory, the max duration in days, if not specified in workspace +durationdefault: 1 # optional, if user does not give duration, this will be used +reminderdefault: 0 # optional, if set, users will always get mail, in doubt local mail to username +maxextensions: 1 # mandatory, the number of extensions, if not specified in workspace +pythonpath: /path/to/my/python # optional, path which is appended to python search path for ws_list and other pythons scripts to find yaml +dbuid: 9999 # mandatory +dbgid: 9999 # mandatory +admins: [hobel] # list of admin users, for ws_list +deldir_timeout: 3600 # maximum time in secs to delete a single workspace. +workspaces: # now the list of the workspaces + lustre: # name of workspace as shown with ws_list -l + keeptime: 1 # mandatory, time in days to keep workspaces after they expired + spaces: [/lustre1/ws, /lustre2/ws] # mandatory, list of directories + spaceselection: random # "random" (default), "uid" (uid%#spaces), "gid" (gid%#spaces) + deleted: .removed # mandatory, will be appended to spaces and database + # to move deleted files to + database: /lustre-db # mandatory, the DB directory, this is where DB files will end + duration: 30 # max duration, overwrites global value + groupdefault: [inst1,inst2] # users of those groups will have this workspace as default + userdefault: [user1] # those users will have this workspace as default + user_acl: [user1] # as soon as user_acl or group_acl exist, + # the workspace is access restricted to those users/groups listed + group_acl: [adm] + maxextensions: 5 # maximum extensions allowed + allocatable: no # do not allow new allocations in this workspace if no + extendable: no # do not allow extensions in this workspace if no + restorable: no # do not allow restores from this workspace if no + nfs: # second workspace, minimum example + keeptime: 1 # mandatory, time in days to keep workspaces after they expired + database: /nfs-db + spaces: [/nfs1/ws] + deleted: .trash