From: parmentelat Date: Mon, 10 Dec 2018 17:34:05 +0000 (+0100) Subject: more python3, esp. in shebangs and doc X-Git-Tag: plcapi-7.0-0~36 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=b6795007cf7200e698ffd7bef79747995ca719a0;p=plcapi.git more python3, esp. in shebangs and doc --- diff --git a/PLC/Config.py b/PLC/Config.py index 78c15093..690f9e36 100644 --- a/PLC/Config.py +++ b/PLC/Config.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # # PLCAPI configuration store. Supports XML-based configuration file # format exported by MyPLC. diff --git a/PLC/Methods/__init__.py b/PLC/Methods/__init__.py index 27e28b21..1eaed823 100644 --- a/PLC/Methods/__init__.py +++ b/PLC/Methods/__init__.py @@ -1,6 +1,3 @@ -#!/usr/bin/python -tt - - import os import glob diff --git a/PLC/Shell.py b/PLC/Shell.py index 48602f7e..41184010 100644 --- a/PLC/Shell.py +++ b/PLC/Shell.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # Interactive shell for testing PLCAPI # diff --git a/PLC/__init__.py b/PLC/__init__.py index 39b6f70a..7b7fc41e 100644 --- a/PLC/__init__.py +++ b/PLC/__init__.py @@ -1,4 +1,2 @@ -#!/usr/bin/python -tt - import os all = [i[:-3] for i in os.listdir(os.path.dirname(__file__)) if i.endswith(".py") and not i.startswith(".")] diff --git a/Server.py b/Server.py index 7b07264f..c0e1f241 100755 --- a/Server.py +++ b/Server.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # Simple standalone HTTP server for testing PLCAPI # diff --git a/aspects/ratelimitaspects.py b/aspects/ratelimitaspects.py index d2aa40d0..a2900793 100644 --- a/aspects/ratelimitaspects.py +++ b/aspects/ratelimitaspects.py @@ -1,4 +1,3 @@ -#!/usr/bin/python #-*- coding: utf-8 -*- # # S.Çağlar Onur diff --git a/doc/DocBook.py b/doc/DocBook.py index edc42ca5..af44f1c7 100755 --- a/doc/DocBook.py +++ b/doc/DocBook.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # Generates a DocBook section documenting all PLCAPI methods on # stdout. diff --git a/doc/DocBookLocal.py b/doc/DocBookLocal.py index 2bed21ab..4e7f960b 100755 --- a/doc/DocBookLocal.py +++ b/doc/DocBookLocal.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from PLC.API import PLCAPI from PLC.Faults import PLCInvalidAPIMethod diff --git a/doc/PLCAPI.xml.in b/doc/PLCAPI.xml.in index 02ed2624..da18878c 100644 --- a/doc/PLCAPI.xml.in +++ b/doc/PLCAPI.xml.in @@ -249,7 +249,7 @@ >>> tagnames=['arch','fcdistro','hrn','hmac','exempt_node_until'] >>> for tt in GetTagTypes(tagnames,['tagname','category']): ->>> ... print "tagname=%-18s category=%s"%(tt['tagname'], tt['category']) +>>> ... print("tagname=%-18s category=%s"%(tt['tagname'], tt['category'])) tagname=hrn category=node/sfa tagname=hmac category=slice/auth tagname=exempt_node_until category=node/myops @@ -419,24 +419,24 @@ LINE 1: ...M view_nodes WHERE deleted IS False AND (True AND hrn ILIKE ... >>> AddNodeGroup('betanodes','deployment','beta') 22 ### checking contents (no node has 'deployment' set to either 'alpha' or 'beta' yet) ->>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print ng +>>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print(ng) {'groupname': u'alphanodes', 'node_ids': []} {'groupname': u'betanodes', 'node_ids': []} ### displaying node ids ->>> for n in GetNodes({'hostname':'*.inria.fr'},['hostname','node_id']): print n +>>> for n in GetNodes({'hostname':'*.inria.fr'},['hostname','node_id']): print(n) {'hostname': u'vnode01.inria.fr', 'node_id': 1} {'hostname': u'vnode02.inria.fr', 'node_id': 2} ### setting 'deployment' for these two nodes >>> SetNodeDeployment('vnode01.inria.fr','alpha') ->>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print ng +>>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print(ng) {'groupname': u'alphanodes', 'node_ids': [1]} {'groupname': u'betanodes', 'node_ids': []} >>> SetNodeDeployment('vnode02.inria.fr','beta') ### checking contents again ->>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print ng +>>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print(ng) {'groupname': u'alphanodes', 'node_ids': [1]} {'groupname': u'betanodes', 'node_ids': [2]} @@ -503,7 +503,7 @@ Type "system.listMethods()" or "help(method)" for more information. the PLC.Shell module: -#!/usr/bin/python +#!/usr/bin/python3 import sys @@ -535,9 +535,9 @@ nodes = plc.GetNodes([121], ['node_id', 'hostname']) the name of all the hosts attached to a given slice. -#!/usr/bin/env python +#!/usr/bin/env python3 -import xmlrpclib +import xmlrpc.client plc_host='www.planet-lab.eu' @@ -550,7 +550,7 @@ auth = { 'AuthMethod' : 'password', api_url="https://%s:443/PLCAPI/"%plc_host -plc_api = xmlrpclib.ServerProxy(api_url,allow_none=True) +plc_api = xmlrpc.client.ServerProxy(api_url,allow_none=True) # the slice's node ids node_ids = plc_api.GetSlices(auth,slice_name,['node_ids'])[0]['node_ids'] diff --git a/migrations/extract-views.py b/migrations/extract-views.py index 02a75242..8add67c8 100755 --- a/migrations/extract-views.py +++ b/migrations/extract-views.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import re diff --git a/tools/dzombie.py b/tools/dzombie.py index d54a5557..e42de3a3 100755 --- a/tools/dzombie.py +++ b/tools/dzombie.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # Tool that removes zombie records from database tables# import sys diff --git a/tools/upgrade-db.py b/tools/upgrade-db.py index 338c55c9..18adaad0 100755 --- a/tools/upgrade-db.py +++ b/tools/upgrade-db.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # Tool for upgrading/converting a db # Requirements: