miscell
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 15 Feb 2017 22:19:48 +0000 (23:19 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 15 Feb 2017 22:19:48 +0000 (23:19 +0100)
Makefile
PLC/Debug.py
PLC/Methods/GetPeers.py
PLC/Methods/GetPersons.py
PLC/Methods/GetSites.py
PLC/Persons.py
php/plc_api.php

index 97061a5..02dd3e4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -76,7 +76,7 @@ ifeq (,$(SSHURL))
        @echo "  make sync PLCHOSTLXC=.. GUESTNAME=.."
        @exit 1
 else
-       +$(RSYNC) plcsh PLC planetlab5.sql migrations aspects $(SSHURL)/usr/share/plc_api/
+       +$(RSYNC) plcsh PLC planetlab5.sql migrations aspects php $(SSHURL)/usr/share/plc_api/
        +$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
        +$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
        $(SSHCOMMAND) /etc/plc.d/httpd stop
index 27f9885..3a9993f 100644 (file)
@@ -39,9 +39,10 @@ def profile(callable):
         start = time.time()
         result = callable(*args, **kwds)
         end = time.time()
-        args = map(str, args)
-        args += ["%s = %s" % (name, str(value)) for (name, value) in kwds.items()]
-        print >> log, "%s (%s): %f s" % (callable.__name__, ", ".join(args), end - start)
+        params = map(str, args)
+        params += ["{} = {}".format(name, value) for (name, value) in kwds.items()]
+        params = ", ".join(params)
+        print >> log, "{} ({}) {:f}s -> {}".format(callable.__name__, params, end - start, result)
         return result
 
     return wrapper
index dca352a..4a77ce4 100644 (file)
@@ -14,13 +14,13 @@ from PLC.Peers import Peer, Peers
 class GetPeers (Method):
     """
     Returns an array of structs containing details about peers. If
-    person_filter is specified and is an array of peer identifiers or
+    peer_filter is specified and is an array of peer identifiers or
     peer names, or a struct of peer attributes, only peers matching
     the filter will be returned. If return_fields is specified, only the
     specified details will be returned.
     """
 
-    roles = ['admin', 'node','pi','user']
+    roles = ['admin', 'node', 'pi', 'user']
 
     accepts = [
         Auth(),
index 06da9f5..53143e0 100644 (file)
@@ -50,7 +50,7 @@ class GetPersons(Method):
                 for site in sites:
                     valid_person_ids += site['person_ids']
             if not valid_person_ids:
-                return []
+                return[]
 
             # this may look suspicious; what if person_filter is not None ?
             # turns out the results are getting filtered again below, so we're safe
@@ -70,7 +70,7 @@ class GetPersons(Method):
         # Must query at least person_id, site_ids, and role_ids (see
         # Person.can_view() and below).
         if return_fields is not None:
-            added_fields = set(['person_id', 'site_ids', 'role_ids','roles']).difference(return_fields)
+            added_fields = set(['person_id', 'site_ids', 'role_ids', 'roles']).difference(return_fields)
             return_fields += added_fields
         else:
             added_fields = []
index d277c28..78eb754 100644 (file)
@@ -19,13 +19,13 @@ class GetSites(Method):
         Auth(),
         Mixed([Mixed(Site.fields['site_id'],
                      Site.fields['login_base'])],
-              Parameter(str,"login_base"),
-              Parameter(int,"site_id"),
+              Parameter(str, "login_base"),
+              Parameter(int, "site_id"),
               Filter(Site.fields)),
         Parameter([str], "List of fields to return", nullok = True)
         ]
 
     returns = [Site.fields]
 
-    def call(self, auth, site_filter = None, return_fields = None):
+    def call(self, auth, site_filter = None, return_fields=None):
         return Sites(self.api, site_filter, return_fields)
index 8276c06..d1b3c79 100644 (file)
@@ -393,11 +393,11 @@ class Persons(Table):
                 person_filter = Filter(Person.fields, {'person_id': ints, 'email': strs})
                 sql += " AND (%s) %s" % person_filter.sql(api, "OR")
             elif isinstance(person_filter, dict):
-                allowed_fields=dict(Person.fields.items()+Person.tags.items())
+                allowed_fields = dict(Person.fields.items() + Person.tags.items())
                 person_filter = Filter(allowed_fields, person_filter)
                 sql += " AND (%s) %s" % person_filter.sql(api, "AND")
             elif isinstance (person_filter, StringTypes):
-                person_filter = Filter(Person.fields, {'email':person_filter})
+                person_filter = Filter(Person.fields, {'email' : person_filter})
                 sql += " AND (%s) %s" % person_filter.sql(api, "AND")
             elif isinstance (person_filter, (int, long)):
                 person_filter = Filter(Person.fields, {'person_id':person_filter})
index 3c878ba..b76b8b3 100644 (file)
@@ -139,9 +139,6 @@ class PLCAPI
     $url .= $this->server . ':' . $this->port . '/' . $this->path;
     curl_setopt($curl, CURLOPT_URL, $url);
 
-    // this tentatively allows to tune mainstream xmlrpc php lib
-    // so as to achieve the same behaviour as with our patched lib
-    $xmlrpc_null_extension = TRUE;
     // Marshal the XML-RPC request as a POST variable. <nil/> is an
     // extension to the XML-RPC spec that is supported in our custom
     // version of xmlrpc.so via the 'allow_null' output_encoding key.
@@ -244,10 +241,15 @@ class PLCAPI
   }
 }
 
+// this tentatively allows to tune mainstream xmlrpc php lib
+// so as to achieve the same behaviour as with our patched lib
+$GLOBALS['xmlrpc_null_extension'] = true;
+$GLOBALS['$xmlrpc_null_apache_encodingn'] = true;
+
 global $adm;
 
 $adm = new PLCAPI(array('AuthMethod' => "capability",
-                       'Username' => PLC_API_MAINTENANCE_USER,
+                       'Username'   => PLC_API_MAINTENANCE_USER,
                        'AuthString' => PLC_API_MAINTENANCE_PASSWORD));
 
 ?>