Skip to content

Commit ceebf99

Browse files
committed
Update for python3
1 parent 568db97 commit ceebf99

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

github-sync.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22
import argparse
33
import json
4-
import urllib2
4+
import urllib3
55
import os
66
import subprocess
77
import re
@@ -18,27 +18,28 @@
1818
args = parser.parse_args()
1919

2020
os.chdir(args.directory)
21-
f = urllib2.urlopen("https://api.github.com/users/%s/repos" % args.user)
22-
repo_list = json.loads(f.read())
21+
http = urllib3.PoolManager()
22+
f = http.request("GET", "https://api.github.com/users/%s/repos" % args.user)
23+
repo_list = json.loads(f.data)
2324

2425
for repo in repo_list:
2526
name, url = repo["name"], repo["clone_url"]
2627
if re.search("[^A-z0-9-_]", name):
27-
print "Skipping invalid name", name
28+
print("Skipping invalid name", name)
2829
continue
2930
if re.search("[^A-z0-9-_:/.]", url):
30-
print "Skipping invalid url", url
31+
print ("Skipping invalid url", url)
3132
continue
3233
if repo["private"]:
33-
print "Skipping private repo", name
34+
print ("Skipping private repo", name)
3435
continue
3536
if repo["fork"] and not args.forks:
36-
print "Skipping forked repo", name
37+
print ("Skipping forked repo", name)
3738
continue
3839
if not os.path.exists(name):
39-
print "New repo", name
40+
print("New repo", name)
4041
subprocess.check_output(["git", "clone", "--mirror", url, name], stderr=subprocess.STDOUT)
4142
os.chdir(name)
42-
print "Updating", name
43+
print("Updating", name)
4344
subprocess.check_output(["git", "remote", "update"])
4445
os.chdir("..")

0 commit comments

Comments
 (0)