Projet

Général

Profil

Révision 91eaee39

ID91eaee39f542967a6934d693c5ae0d608e69e1e1
Parent 4a6d44a4
Enfant a10647b9

Ajouté par Lars Kruse il y a environ 5 ans

Plugin lighttpd_: migrate to Python3

Voir les différences:

plugins/lighttpd/lighttpd_
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# vim: set fileencoding=utf-8
1
#!/usr/bin/env python3
4 2
"""
5 3

  
6 4
=head1 NAME
......
54 52

  
55 53
import os
56 54
import sys
57
import urllib2
55
import urllib.request
58 56

  
59 57

  
60 58
program = sys.argv[0]
......
114 112
else:
115 113
    status_url = os.environ.get('status_url', 'http://127.0.0.1/server-status')
116 114

  
117
    request = urllib2.Request("%s?auto" % status_url)
115
    request = urllib.request.Request("%s?auto" % status_url)
118 116
    if "username" in os.environ and "password" in os.environ:
119
        mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
117
        mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
120 118
        mgr.add_password(None, status_url, os.environ["username"], os.environ["password"])
121 119
        if os.environ.get("auth_type", "basic") == "digest":
122
            auth = urllib2.HTTPDigestAuthHandler(mgr)
120
            auth = urllib.request.HTTPDigestAuthHandler(mgr)
123 121
        else:
124
            auth = urllib2.HTTPBasicAuthHandler(mgr)
125
        opener = urllib2.build_opener(auth)
126
        urllib2.install_opener(opener)
127
    info = urllib2.urlopen(request).read()
122
            auth = urllib.request.HTTPBasicAuthHandler(mgr)
123
        opener = urllib.request.build_opener(auth)
124
        urllib.request.install_opener(opener)
125
    info = urllib.request.urlopen(request).read()
128 126
    data = {}
129 127
    for line in info.split("\n"):
130 128
        try:

Formats disponibles : Unified diff