gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r16498 - gnunet/contrib


From: gnunet
Subject: [GNUnet-SVN] r16498 - gnunet/contrib
Date: Sun, 14 Aug 2011 16:29:19 +0200

Author: grothoff
Date: 2011-08-14 16:29:19 +0200 (Sun, 14 Aug 2011)
New Revision: 16498

Added:
   gnunet/contrib/gnunet_janitor.py.in
Modified:
   gnunet/contrib/Makefile.am
Log:
LRN: gnunet janitor -- another killall variant

Modified: gnunet/contrib/Makefile.am
===================================================================
--- gnunet/contrib/Makefile.am  2011-08-14 14:28:07 UTC (rev 16497)
+++ gnunet/contrib/Makefile.am  2011-08-14 14:29:19 UTC (rev 16498)
@@ -7,7 +7,8 @@
 endif
 
 noinst_SCRIPTS = \
- gnunet_pyexpect.py
+ gnunet_pyexpect.py \
+ gnunet_janitor.py
 
 dist_pkgdata_DATA = \
  gnunet-logo-color.png \
@@ -18,15 +19,15 @@
  hostlist.cgi \
  hostlist.php \
  report.sh \
- gnunet_pyexpect.py.in
+ gnunet_pyexpect.py.in \
+ gnunet_janitor.py.in
 
 do_subst = $(SED) -e 's,address@hidden@],$(PYTHON),g'
 
-gnunet_pyexpect.py: gnunet_pyexpect.py.in Makefile
-       $(do_subst) < $(srcdir)/gnunet_pyexpect.py.in > gnunet_pyexpect.py
-       chmod +x gnunet_pyexpect.py
+%.py: %.py.in Makefile
+       $(do_subst) < $(srcdir)/$< > $@
+       chmod +x $@
 
-
 # init_gnunet_redhat \
 # init_gnunet_ubuntu \
 # visualize_stats.sh \

Added: gnunet/contrib/gnunet_janitor.py.in
===================================================================
--- gnunet/contrib/gnunet_janitor.py.in                         (rev 0)
+++ gnunet/contrib/gnunet_janitor.py.in 2011-08-14 14:29:19 UTC (rev 16498)
@@ -0,0 +1,62 @@
address@hidden@
+#    This file is part of GNUnet.
+#    (C) 2011 Christian Grothoff (and other contributing authors)
+#
+#    GNUnet 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, or (at your
+#    option) any later version.
+#
+#    GNUnet 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 GNUnet; see the file COPYING.  If not, write to the
+#    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+#    Boston, MA 02111-1307, USA.
+#
+# Finds any gnunet processes still running in the system and kills them
+from __future__ import print_function
+import os
+import re
+import subprocess
+import sys
+import shutil
+import time
+import signal
+
+if os.name == 'nt':
+  from win32com.client import GetObject
+  WMI = GetObject('winmgmts:')
+
+def get_process_list ():
+  result = []
+  if os.name == 'nt':
+    processes = WMI.InstancesOf('Win32_Process')
+    for p in processes:
+      result.append ((p.Properties_('ProcessId').Value, re.sub (r'(.+)\.exe', 
r'\1', p.Properties_('Name').Value)))
+  else:
+    pids = [pid for pid in os.listdir('/proc') if pid.isdigit ()]
+    for pid in pids:
+      result.append ((pid, open (os.path.join ('/proc', pid, 'comm'), 
'rb').read ()
+  return result
+
+def main ():
+  procs = get_process_list ()
+  gnunet_procs = []
+  for p in procs:
+    if re.match (r'gnunet-.+', p[1]):
+      gnunet_procs.append (p)
+  for p in gnunet_procs:
+    if re.match (r'gnunet-service-arm', p[1]):
+      print ("killing arm {0:5} {1}".format (p[0], p[1]))
+      os.kill (p[0], signal.SIGTERM)
+  for p in gnunet_procs:
+    if not re.match (r'gnunet-service-arm', p[1]):
+      print ("killing arm {0:5} {1}".format (p[0], p[1]))
+      os.kill (p[0], signal.SIGTERM)
+
+if __name__ == '__main__':
+  sys.exit (main ())
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]