diff --git a/debian/control b/debian/control index 218c0be..4ec0b8e 100644 --- a/debian/control +++ b/debian/control @@ -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 diff --git a/lib/systemd/system/ahenk.service b/lib/systemd/system/ahenk.service index 4efe333..a0e563f 100644 --- a/lib/systemd/system/ahenk.service +++ b/lib/systemd/system/ahenk.service @@ -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 \ No newline at end of file +WantedBy=multi-user.target diff --git a/opt/ahenk/ahenkd.py b/opt/ahenk/ahenkd.py index 17faa99..3f4ab81 100644 --- a/opt/ahenk/ahenkd.py +++ b/opt/ahenk/ahenkd.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN @@ -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) diff --git a/opt/ahenk/api/service/ps_util.py b/opt/ahenk/api/service/ps_util.py index 2f25859..222c998 100644 --- a/opt/ahenk/api/service/ps_util.py +++ b/opt/ahenk/api/service/ps_util.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN import psutil diff --git a/opt/ahenk/base/Scope.py b/opt/ahenk/base/Scope.py index d33abc5..a315800 100644 --- a/opt/ahenk/base/Scope.py +++ b/opt/ahenk/base/Scope.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # @author: İsmail BAŞARAN diff --git a/opt/ahenk/base/config/ConfigManager.py b/opt/ahenk/base/config/ConfigManager.py index a819c1b..8e54712 100644 --- a/opt/ahenk/base/config/ConfigManager.py +++ b/opt/ahenk/base/config/ConfigManager.py @@ -1,17 +1,17 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN -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 \ No newline at end of file + return parser diff --git a/opt/ahenk/base/deamon/BaseDeamon.py b/opt/ahenk/base/deamon/BaseDeamon.py index 38af4ba..a2252ef 100644 --- a/opt/ahenk/base/deamon/BaseDeamon.py +++ b/opt/ahenk/base/deamon/BaseDeamon.py @@ -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): diff --git a/opt/ahenk/base/logger/AhenkLogger.py b/opt/ahenk/base/logger/AhenkLogger.py index e60aac0..3a0c814 100644 --- a/opt/ahenk/base/logger/AhenkLogger.py +++ b/opt/ahenk/base/logger/AhenkLogger.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN import sys diff --git a/opt/ahenk/base/logging/AhenkLogger.py b/opt/ahenk/base/logging/AhenkLogger.py index a37e0c9..66e08ee 100644 --- a/opt/ahenk/base/logging/AhenkLogger.py +++ b/opt/ahenk/base/logging/AhenkLogger.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN import sys diff --git a/opt/ahenk/base/plugin/AbstractPlugin.py b/opt/ahenk/base/plugin/AbstractPlugin.py index 7174450..7ea2872 100644 --- a/opt/ahenk/base/plugin/AbstractPlugin.py +++ b/opt/ahenk/base/plugin/AbstractPlugin.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN diff --git a/opt/ahenk/base/plugin/Plugin.py b/opt/ahenk/base/plugin/Plugin.py index 0510dea..a7186c6 100644 --- a/opt/ahenk/base/plugin/Plugin.py +++ b/opt/ahenk/base/plugin/Plugin.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN diff --git a/opt/ahenk/base/plugin/PluginManager.py b/opt/ahenk/base/plugin/PluginManager.py index 6ab844c..db0be7d 100644 --- a/opt/ahenk/base/plugin/PluginManager.py +++ b/opt/ahenk/base/plugin/PluginManager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN from base.plugin.Plugin import Plugin diff --git a/opt/ahenk/plugins/plugin1/main.py b/opt/ahenk/plugins/plugin1/main.py index d01e893..859693f 100644 --- a/opt/ahenk/plugins/plugin1/main.py +++ b/opt/ahenk/plugins/plugin1/main.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN diff --git a/opt/ahenk/plugins/plugin2/main.py b/opt/ahenk/plugins/plugin2/main.py index 0465cf4..addbdbb 100644 --- a/opt/ahenk/plugins/plugin2/main.py +++ b/opt/ahenk/plugins/plugin2/main.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN