Retranscription code Python en code PHP
Bonjour, d'abord désolé par avance si je n'ai pas posté dans le bon forum.
Je vous contact car mon problème est le suivant :
J'aimerais retranscrire ou transformer un code Python en code PHP.
C'est pour un exercice afin de différencier les avantages et les inconvénients entre le language PHP et
python du point de vue pratique.
Mon code python est le suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| #!/usr/bin/python
# -*-coding:Latin-1 -*
# Import lib
import xmlrpclib
import re
import datetime
from time import mktime, strptime
# Exemple de connexion server
SERVER_URL = "http://test.com"
SERVER_LOGIN = "test"
SERVER_PASSWORD = "test"
client = xmlrpclib.Server(SERVER_URL, verbose=0)
key = client.auth.login(SERVER_LOGIN, SERVER_PASSWORD)
LIST_STATION = ""
# Récupération de toute ma liste de stations
list_systems = client.system.listSystems(key)
for system in list_systems:
SYSNAME = system["name"]
list_id = client.system.getId(key,SYSNAME)
# Date convertit au format %d/%m/%Y à %H:%M:%S
checkdate = list_id[0]['last_checkin']
di = datetime.datetime.strptime( str(checkdate), "%Y%m%dT%H:%M:%S" )
dfrmt = di.strftime("%d/%m/%Y à %H:%M:%S")
# ID
id = list_id[0]['id']
# Nom
name = list_id[0]['name']
# Transformation de toutes mes chaines en une seule chaine
LIST_STATION = LIST_STATION + " " + name + " " + str(id) + " " + dfrmt
#LIST_STATION = name + " " + str(id) + " " + str(checkdate) + " " + LIST_STATION
print LIST_STATION[1:]
client.auth.logout(key) |
Auriez vous une idée svp?
Cdt,