X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=conf_files.py;h=8bc3186b1dd4931d3246259341663bfc6bee23c9;hb=e4069fdeaf5f672c866f3c9e5eb489284790c36c;hp=7b0cadae0ae1927ccffda1c5e66c23481bf9b8af;hpb=48a73b18fd7daed13c645c1adeddb57b560e7a2d;p=nodemanager.git diff --git a/conf_files.py b/conf_files.py old mode 100644 new mode 100755 index 7b0cada..8bc3186 --- a/conf_files.py +++ b/conf_files.py @@ -1,18 +1,16 @@ +#!/usr/bin/env python3 + """configuration files""" import grp import os import pwd -try: - from hashlib import sha1 as sha -except ImportError: - from sha import sha -import string +from hashlib import sha1 as sha +import xmlrpc.client import curlwrapper import logger import tools -import xmlrpc.client from config import Config # right after net @@ -38,10 +36,11 @@ class conf_files: else: return 0 def update_conf_file(self, cf_rec): - if not cf_rec['enabled']: return + if not cf_rec['enabled']: + return dest = cf_rec['dest'] err_cmd = cf_rec['error_cmd'] - mode = string.atoi(cf_rec['file_permissions'], base=8) + mode = int(cf_rec['file_permissions'], base=8) try: uid = pwd.getpwnam(cf_rec['file_owner'])[2] except: @@ -55,8 +54,8 @@ class conf_files: url = 'https://%s/%s' % (self.config.PLC_BOOT_HOST, cf_rec['source']) # set node_id at the end of the request - hacky if tools.node_id(): - if url.find('?') >0: url += '&' - else: url += '?' + if url.find('?') > 0: url += '&' + else: url += '?' url += "node_id=%d"%tools.node_id() else: logger.log('conf_files: %s -- WARNING, cannot add node_id to request'%dest)