[Dextrose] [PATCH][Dx2][dx-platform] Trigger activities updater
Martin Abente
martin.abente.lahaye at gmail.com
Fri Apr 29 20:32:53 EDT 2011
Trigger the current sugar activities
updates alert once per month.
#Implements #2781
---
etc/cron.monthly/sugar-updater | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
create mode 100644 etc/cron.monthly/sugar-updater
diff --git a/etc/cron.monthly/sugar-updater b/etc/cron.monthly/sugar-updater
new file mode 100644
index 0000000..592fb1a
--- /dev/null
+++ b/etc/cron.monthly/sugar-updater
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# Copyright (C) 2011, Martin Abente
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import os
+import pwd
+
+HOME = '/home/'
+TRIGGER = '.sugar-update'
+
+for user in os.listdir(HOME):
+ home_dir = os.path.join(HOME, user)
+
+ if not os.path.isdir(home_dir):
+ continue
+ trigger_path = os.path.join(home_dir, TRIGGER)
+
+ try:
+ pw_info = pwd.getpwnam(user)
+ trigger_file = open(trigger_path, 'w')
+ trigger_file.close()
+ os.chown(trigger_path, pw_info.pw_uid, pw_info.pw_gid)
+ except:
+ print 'Could not create trigger: %s' % trigger_path
--
1.7.4.4
More information about the Dextrose
mailing list