[projects/git-slug: 81/170] Change paths defined to use by watch daemon to relative ones

glen glen at pld-linux.org
Mon Sep 21 21:45:37 CEST 2015


commit e33e60aa54ba06de2deb452edc1decca39ecbf38
Author: Kacper Kornet <draenog at pld-linux.org>
Date:   Mon Mar 5 15:49:49 2012 +0000

    Change paths defined to use by watch daemon to relative ones
    
    It is in preparation for the possibility for watch daemon to change uid.

 git_slug/serverconst.py            |  4 +---
 post-receive.python.d/slug_hook.py |  2 ++
 slug_watch                         | 10 ++++++----
 3 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/git_slug/serverconst.py b/git_slug/serverconst.py
index 3d176ea..0ce3f86 100644
--- a/git_slug/serverconst.py
+++ b/git_slug/serverconst.py
@@ -1,3 +1 @@
-from os.path import join, expanduser
-
-WATCHDIR = expanduser('~/watchdir')
+WATCHDIR = 'watchdir'
diff --git a/post-receive.python.d/slug_hook.py b/post-receive.python.d/slug_hook.py
index efb6346..fc49c04 100644
--- a/post-receive.python.d/slug_hook.py
+++ b/post-receive.python.d/slug_hook.py
@@ -5,6 +5,8 @@ from git_slug.serverconst import WATCHDIR
 
 
 def run(data):
+    global WATCHDIR
+    WATCHDIR = os.path.join(os.path.expanduser('~'), WATCHDIR)
     gitrepo = os.environ.get('GL_REPO')
     if gitrepo.startswith('packages/'):
         gitrepo = gitrepo[len('packages/'):]
diff --git a/slug_watch b/slug_watch
index de729bf..6c1800f 100755
--- a/slug_watch
+++ b/slug_watch
@@ -3,6 +3,7 @@
 import fcntl
 import heapq
 import os
+import pwd
 import pyinotify
 
 from git_slug.gitconst import EMPTYSHA1, REFREPO, REFFILE
@@ -10,10 +11,10 @@ from git_slug.serverconst import WATCHDIR
 from git_slug.refsdata import RemoteRefsData
 from git_slug.gitrepo import GitRepo
 
-PIDFILE = os.path.expanduser('~/watch.pid')
+PIDFILE = 'watch.pid'
 REFFILE_NEW = REFFILE + '.new'
-REFREPO_WDIR = os.path.expanduser('~/Refs')
-REFREPO_GDIR = os.path.join(os.path.expanduser('~/repositories'), REFREPO+'.git')
+REFREPO_WDIR = 'Refs'
+REFREPO_GDIR = os.path.join('repositories', REFREPO+'.git')
 
 WATCHDIR=WATCHDIR
 
@@ -71,7 +72,8 @@ def run():
         process_file(os.path.join(WATCHDIR,filename))
     notifier.loop()
 
-with open(os.path.expanduser(PIDFILE), "a") as f:
+os.chdir(pwd.getpwuid(os.getuid()).pw_dir)
+with open(PIDFILE, "a") as f:
     try: 
         fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
         run()
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5



More information about the pld-cvs-commit mailing list