Skip to content

Commit 7643ae0

Browse files
committed
Python 3 compatibility
1 parent 152efd8 commit 7643ae0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

kc-compat.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
from __future__ import print_function
12
import struct
2-
import urllib2
33
import sys
44
import os
55

6+
try:
7+
from urllib.request import urlopen
8+
except ImportError:
9+
from urllib2 import urlopen
10+
611
__author__ = 'Igor Seletskiy'
712
__copyright__ = "Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc"
813
__credits__ = 'Igor Seletskiy'
@@ -62,11 +67,11 @@ def inside_lxc_container():
6267

6368

6469
def is_compat():
65-
url = 'http://patches.kernelcare.com/'+get_kernel_hash()+'/version'
70+
url = 'http://patches.kernelcare.com/' + get_kernel_hash() + '/version'
6671
try:
67-
urllib2.urlopen(url)
72+
urlopen(url)
6873
return True
69-
except:
74+
except Exception:
7075
return False
7176

7277

@@ -95,5 +100,6 @@ def main():
95100
myprint(silent, "UNSUPPORTED")
96101
return 1
97102

103+
98104
if __name__ == "__main__":
99105
exit(main())

0 commit comments

Comments
 (0)