modified for compiling python3

This commit is contained in:
Volkan Şahin 2016-02-29 10:48:00 +02:00
parent a22487f8ce
commit e082797042
14 changed files with 38 additions and 38 deletions

2
debian/control vendored
View File

@ -8,6 +8,6 @@ Homepage: http://www.liderahenk.org.tr
Package: ahenk
Architecture: any
Depends:python-deamon, python2.7 (>= 2.7.3)
Depends:python-deamon, python3 (>= 3)
Description: LiderAhenk agent application
Long Desc

View File

@ -4,9 +4,9 @@ After=network.target
[Service]
Type=forking
ExecStart=python "/opt/ahenk/ahenkd.py start"
ExecStop=python "/opt/ahenk/ahenkd.py stop"
ExecStart=python3 "/opt/ahenk/ahenkd.py start"
ExecStop=python3 "/opt/ahenk/ahenkd.py stop"
PIDFile=/var/run/ahenkd.pid
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
@ -14,7 +14,7 @@ class AhenkDeamon(BaseDaemon):
"""docstring for AhenkDeamon"""
def run(self):
print "merhaba dunya"
print ("merhaba dunya")
globalscope = Scope()
globalscope.setInstance(globalscope)
@ -37,23 +37,23 @@ if __name__ == '__main__':
ahenkdaemon = AhenkDeamon(pidfilePath)
print sys.argv
print (sys.argv)
if len(sys.argv) == 2:
if sys.argv[1] == "start":
print "starting"
print ("starting")
ahenkdaemon.start()
print ahenkdaemon.get_pid()
print (ahenkdaemon.get_pid())
elif sys.argv[1] == 'stop':
ahenkdaemon.stop()
elif sys.argv[1] == 'restart':
ahenkdaemon.restart()
elif sys.argv[1] == 'status':
# print status
# print (status)
pass
else:
print 'Unknown command. Usage : %s start|stop|restart|status' % sys.argv[0]
print ('Unknown command. Usage : %s start|stop|restart|status' % sys.argv[0])
sys.exit(2)
sys.exit(0)
else:
print 'Usage : %s start|stop|restart|status' % sys.argv[0]
print ('Usage : %s start|stop|restart|status' % sys.argv[0])
sys.exit(2)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
import psutil

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>

View File

@ -1,17 +1,17 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
import ConfigParser,os
import configparser,os
from os import listdir
from os.path import isfile, join
from ConfigParser import SafeConfigParser
from configparser import SafeConfigParser
class ConfigManager(object):
"""
This class written for configuration file management of ahenk and ahenk plugins
Sample ahenk configuration file path /etc/ahenk/ahenk.conf and sample ahenk plugins configuration folder path /etc/ahenk/config.d/
Usage: Takes two argument, - both of them are optional - one of the is a configuration file path the other one
Usage: Takes two argument, - both of them are optional - one of the is a configuration file path the other one
is configuration files folder path
"""
def __init__(self, configurationFilePath=None, configurationFolderPath=None):
@ -38,4 +38,4 @@ class ConfigManager(object):
parser = SafeConfigParser()
configValues = parser.read(configFiles)
return parser
return parser

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys, os, time, atexit
from signal import SIGTERM
@ -28,7 +28,7 @@ class BaseDaemon(object):
if pid > 0:
# exit first parent
sys.exit(0)
except OSError, e:
except OSError as e:
sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror))
sys.exit(1)
@ -43,14 +43,14 @@ class BaseDaemon(object):
if pid > 0:
# exit from second parent
sys.exit(0)
except OSError, e:
except OSError as e:
sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror))
sys.exit(1)
# redirect standard file descriptors
si = file(self.stdin, 'r')
so = file(self.stdout, 'a+')
se = file(self.stderr, 'a+', 0)
si = open(self.stdin, 'r')
so = open(self.stdout, 'a+')
se = open(self.stderr, 'a+')
pid = str(os.getpid())
@ -58,7 +58,7 @@ class BaseDaemon(object):
sys.stderr.flush()
if self.pidfile:
file(self.pidfile,'w+').write("%s\n" % pid)
open(self.pidfile,'w+').write("%s\n" % pid)
atexit.register(self.delpid)
os.dup2(si.fileno(), sys.stdin.fileno())
@ -77,7 +77,7 @@ class BaseDaemon(object):
"""
# Check for a pidfile to see if the daemon already runs
try:
pf = file(self.pidfile,'r')
pf = open(self.pidfile,'r')
pid = int(pf.read().strip())
pf.close()
except IOError:
@ -98,7 +98,7 @@ class BaseDaemon(object):
"""
# Get the pid from the pidfile
try:
pf = file(self.pidfile,'r')
pf = open(self.pidfile,'r')
pid = int(pf.read().strip())
pf.close()
except IOError:
@ -114,13 +114,13 @@ class BaseDaemon(object):
while 1:
os.kill(pid, SIGTERM)
time.sleep(0.1)
except OSError, err:
except OSError as err:
err = str(err)
if err.find("No such process") > 0:
if os.path.exists(self.pidfile):
os.remove(self.pidfile)
else:
print str(err)
print(str(err))
sys.exit(1)
def restart(self):

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
import sys

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
import sys

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
from base.plugin.Plugin import Plugin

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>