github-backup 0.44.0__py3-none-any.whl → 0.45.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- github_backup/__init__.py +1 -1
- github_backup/github_backup.py +41 -21
- {github_backup-0.44.0.data → github_backup-0.45.0.data}/scripts/github-backup +13 -11
- {github_backup-0.44.0.dist-info → github_backup-0.45.0.dist-info}/METADATA +8 -2
- github_backup-0.45.0.dist-info/RECORD +9 -0
- github_backup-0.44.0.dist-info/RECORD +0 -9
- {github_backup-0.44.0.dist-info → github_backup-0.45.0.dist-info}/LICENSE.txt +0 -0
- {github_backup-0.44.0.dist-info → github_backup-0.45.0.dist-info}/WHEEL +0 -0
- {github_backup-0.44.0.dist-info → github_backup-0.45.0.dist-info}/top_level.txt +0 -0
- {github_backup-0.44.0.dist-info → github_backup-0.45.0.dist-info}/zip-safe +0 -0
github_backup/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.45.0"
|
github_backup/github_backup.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
|
|
3
3
|
from __future__ import print_function
|
|
4
|
-
import socket
|
|
5
4
|
|
|
6
5
|
import argparse
|
|
7
6
|
import base64
|
|
@@ -10,23 +9,21 @@ import codecs
|
|
|
10
9
|
import errno
|
|
11
10
|
import getpass
|
|
12
11
|
import json
|
|
12
|
+
import logging
|
|
13
13
|
import os
|
|
14
|
+
import platform
|
|
14
15
|
import re
|
|
15
16
|
import select
|
|
17
|
+
import socket
|
|
16
18
|
import subprocess
|
|
17
19
|
import sys
|
|
18
|
-
import logging
|
|
19
20
|
import time
|
|
20
|
-
import platform
|
|
21
|
-
from urllib.parse import urlparse
|
|
22
|
-
from urllib.parse import quote as urlquote
|
|
23
|
-
from urllib.parse import urlencode
|
|
24
|
-
from urllib.error import HTTPError, URLError
|
|
25
|
-
from urllib.request import urlopen
|
|
26
|
-
from urllib.request import Request
|
|
27
|
-
from urllib.request import HTTPRedirectHandler
|
|
28
|
-
from urllib.request import build_opener
|
|
29
21
|
from http.client import IncompleteRead
|
|
22
|
+
from urllib.error import HTTPError, URLError
|
|
23
|
+
from urllib.parse import quote as urlquote
|
|
24
|
+
from urllib.parse import urlencode, urlparse
|
|
25
|
+
from urllib.request import HTTPRedirectHandler, Request, build_opener, urlopen
|
|
26
|
+
from datetime import datetime
|
|
30
27
|
|
|
31
28
|
try:
|
|
32
29
|
from . import __version__
|
|
@@ -41,10 +38,7 @@ logger = logging.getLogger(__name__)
|
|
|
41
38
|
|
|
42
39
|
|
|
43
40
|
def logging_subprocess(
|
|
44
|
-
popenargs,
|
|
45
|
-
stdout_log_level=logging.DEBUG,
|
|
46
|
-
stderr_log_level=logging.ERROR,
|
|
47
|
-
**kwargs
|
|
41
|
+
popenargs, stdout_log_level=logging.DEBUG, stderr_log_level=logging.ERROR, **kwargs
|
|
48
42
|
):
|
|
49
43
|
"""
|
|
50
44
|
Variant of subprocess.call that accepts a logger instead of stdout/stderr,
|
|
@@ -383,6 +377,19 @@ def parse_args(args=None):
|
|
|
383
377
|
dest="include_releases",
|
|
384
378
|
help="include release information, not including assets or binaries",
|
|
385
379
|
)
|
|
380
|
+
parser.add_argument(
|
|
381
|
+
"--latest-releases",
|
|
382
|
+
type=int,
|
|
383
|
+
default=0,
|
|
384
|
+
dest="number_of_latest_releases",
|
|
385
|
+
help="include certain number of the latest releases; only applies if including releases",
|
|
386
|
+
)
|
|
387
|
+
parser.add_argument(
|
|
388
|
+
"--skip-prerelease",
|
|
389
|
+
action="store_true",
|
|
390
|
+
dest="skip_prerelease",
|
|
391
|
+
help="skip prerelease and draft versions; only applies if including releases",
|
|
392
|
+
)
|
|
386
393
|
parser.add_argument(
|
|
387
394
|
"--assets",
|
|
388
395
|
action="store_true",
|
|
@@ -504,7 +511,7 @@ def get_github_host(args):
|
|
|
504
511
|
|
|
505
512
|
|
|
506
513
|
def read_file_contents(file_uri):
|
|
507
|
-
return open(file_uri[len(FILE_URI_PREFIX)
|
|
514
|
+
return open(file_uri[len(FILE_URI_PREFIX):], "rt").readline().strip()
|
|
508
515
|
|
|
509
516
|
|
|
510
517
|
def get_github_repo_url(args, repository):
|
|
@@ -626,12 +633,12 @@ def retrieve_data_gen(args, template, query_args=None, single_request=False):
|
|
|
626
633
|
raise Exception(", ".join(errors))
|
|
627
634
|
|
|
628
635
|
if len(errors) == 0:
|
|
629
|
-
if type(response)
|
|
636
|
+
if type(response) is list:
|
|
630
637
|
for resp in response:
|
|
631
638
|
yield resp
|
|
632
639
|
if len(response) < per_page:
|
|
633
640
|
break
|
|
634
|
-
elif type(response)
|
|
641
|
+
elif type(response) is dict and single_request:
|
|
635
642
|
yield response
|
|
636
643
|
|
|
637
644
|
if len(errors) > 0:
|
|
@@ -1196,8 +1203,11 @@ def backup_hooks(args, repo_cwd, repository, repos_template):
|
|
|
1196
1203
|
template = "{0}/{1}/hooks".format(repos_template, repository["full_name"])
|
|
1197
1204
|
try:
|
|
1198
1205
|
_backup_data(args, "hooks", template, output_file, hook_cwd)
|
|
1199
|
-
except
|
|
1200
|
-
|
|
1206
|
+
except Exception as e:
|
|
1207
|
+
if "404" in str(e):
|
|
1208
|
+
logger.info("Unable to read hooks, skipping")
|
|
1209
|
+
else:
|
|
1210
|
+
raise e
|
|
1201
1211
|
|
|
1202
1212
|
|
|
1203
1213
|
def backup_releases(args, repo_cwd, repository, repos_template, include_assets=False):
|
|
@@ -1213,8 +1223,18 @@ def backup_releases(args, repo_cwd, repository, repos_template, include_assets=F
|
|
|
1213
1223
|
release_template = "{0}/{1}/releases".format(repos_template, repository_fullname)
|
|
1214
1224
|
releases = retrieve_data(args, release_template, query_args=query_args)
|
|
1215
1225
|
|
|
1226
|
+
if args.skip_prerelease:
|
|
1227
|
+
releases = [r for r in releases if not r["prerelease"] and not r["draft"]]
|
|
1228
|
+
|
|
1229
|
+
if args.number_of_latest_releases and args.number_of_latest_releases < len(releases):
|
|
1230
|
+
releases.sort(key=lambda item: datetime.strptime(item["created_at"], "%Y-%m-%dT%H:%M:%SZ"),
|
|
1231
|
+
reverse=True)
|
|
1232
|
+
releases = releases[:args.number_of_latest_releases]
|
|
1233
|
+
logger.info("Saving the latest {0} releases to disk".format(len(releases)))
|
|
1234
|
+
else:
|
|
1235
|
+
logger.info("Saving {0} releases to disk".format(len(releases)))
|
|
1236
|
+
|
|
1216
1237
|
# for each release, store it
|
|
1217
|
-
logger.info("Saving {0} releases to disk".format(len(releases)))
|
|
1218
1238
|
for release in releases:
|
|
1219
1239
|
release_name = release["tag_name"]
|
|
1220
1240
|
release_name_safe = release_name.replace("/", "__")
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
#!python
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
format='%(asctime)s.%(msecs)03d: %(message)s',
|
|
7
|
-
datefmt='%Y-%m-%dT%H:%M:%S',
|
|
8
|
-
level=logging.INFO
|
|
9
|
-
)
|
|
3
|
+
import logging
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
10
6
|
|
|
11
7
|
from github_backup.github_backup import (
|
|
12
8
|
backup_account,
|
|
@@ -20,6 +16,12 @@ from github_backup.github_backup import (
|
|
|
20
16
|
retrieve_repositories,
|
|
21
17
|
)
|
|
22
18
|
|
|
19
|
+
logging.basicConfig(
|
|
20
|
+
format="%(asctime)s.%(msecs)03d: %(message)s",
|
|
21
|
+
datefmt="%Y-%m-%dT%H:%M:%S",
|
|
22
|
+
level=logging.INFO,
|
|
23
|
+
)
|
|
24
|
+
|
|
23
25
|
|
|
24
26
|
def main():
|
|
25
27
|
args = parse_args()
|
|
@@ -29,7 +31,7 @@ def main():
|
|
|
29
31
|
|
|
30
32
|
output_directory = os.path.realpath(args.output_directory)
|
|
31
33
|
if not os.path.isdir(output_directory):
|
|
32
|
-
logger.info(
|
|
34
|
+
logger.info("Create output directory {0}".format(output_directory))
|
|
33
35
|
mkdir_p(output_directory)
|
|
34
36
|
|
|
35
37
|
if args.lfs_clone:
|
|
@@ -41,10 +43,10 @@ def main():
|
|
|
41
43
|
logger.root.setLevel(log_level)
|
|
42
44
|
|
|
43
45
|
if not args.as_app:
|
|
44
|
-
logger.info(
|
|
46
|
+
logger.info("Backing up user {0} to {1}".format(args.user, output_directory))
|
|
45
47
|
authenticated_user = get_authenticated_user(args)
|
|
46
48
|
else:
|
|
47
|
-
authenticated_user = {
|
|
49
|
+
authenticated_user = {"login": None}
|
|
48
50
|
|
|
49
51
|
repositories = retrieve_repositories(args, authenticated_user)
|
|
50
52
|
repositories = filter_repositories(args, repositories)
|
|
@@ -52,7 +54,7 @@ def main():
|
|
|
52
54
|
backup_account(args, output_directory)
|
|
53
55
|
|
|
54
56
|
|
|
55
|
-
if __name__ ==
|
|
57
|
+
if __name__ == "__main__":
|
|
56
58
|
try:
|
|
57
59
|
main()
|
|
58
60
|
except Exception as e:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: github-backup
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.45.0
|
|
4
4
|
Summary: backup a github user or organization
|
|
5
5
|
Home-page: http://github.com/josegonzalez/python-github-backup
|
|
6
6
|
Author: Jose Diaz-Gonzalez
|
|
@@ -67,7 +67,9 @@ CLI Help output::
|
|
|
67
67
|
[-P] [-F] [--prefer-ssh] [-v]
|
|
68
68
|
[--keychain-name OSX_KEYCHAIN_ITEM_NAME]
|
|
69
69
|
[--keychain-account OSX_KEYCHAIN_ITEM_ACCOUNT]
|
|
70
|
-
[--releases] [--
|
|
70
|
+
[--releases] [--latest-releases NUMBER_OF_LATEST_RELEASES]
|
|
71
|
+
[--skip-prerelease] [--assets]
|
|
72
|
+
[--exclude [REPOSITORY [REPOSITORY ...]]
|
|
71
73
|
[--throttle-limit THROTTLE_LIMIT] [--throttle-pause THROTTLE_PAUSE]
|
|
72
74
|
USER
|
|
73
75
|
|
|
@@ -142,6 +144,10 @@ CLI Help output::
|
|
|
142
144
|
keychain that holds the personal access or OAuth token
|
|
143
145
|
--releases include release information, not including assets or
|
|
144
146
|
binaries
|
|
147
|
+
--latest-releases NUMBER_OF_LATEST_RELEASES
|
|
148
|
+
include certain number of the latest releases;
|
|
149
|
+
only applies if including releases
|
|
150
|
+
--skip-prerelease skip prerelease and draft versions; only applies if including releases
|
|
145
151
|
--assets include assets alongside release information; only
|
|
146
152
|
applies if including releases
|
|
147
153
|
--exclude [REPOSITORY [REPOSITORY ...]]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
github_backup/__init__.py,sha256=p2Xvd610sh3godS2s3KpBCKAbfwwnEs-mH0Q6wQI5LE,23
|
|
2
|
+
github_backup/github_backup.py,sha256=4DX06Tbj6QtSRgEsWBNWqV1cvrryZBvf7RUmxDlG2dg,47687
|
|
3
|
+
github_backup-0.45.0.data/scripts/github-backup,sha256=I79TNA67phytRmI9nm_LlD9h2zauXFOsOn9tYyAy9pU,1546
|
|
4
|
+
github_backup-0.45.0.dist-info/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
|
|
5
|
+
github_backup-0.45.0.dist-info/METADATA,sha256=fRe-Ut7k4UVvklGr4nWUNPowGMQoKvnaF5wGZLrx16o,18970
|
|
6
|
+
github_backup-0.45.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
7
|
+
github_backup-0.45.0.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
|
|
8
|
+
github_backup-0.45.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
9
|
+
github_backup-0.45.0.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
github_backup/__init__.py,sha256=jLVEw0OXaD-GYhTB6M4c0IS8rVCF3biDLYCxt25hxuA,23
|
|
2
|
-
github_backup/github_backup.py,sha256=GnsnNhdLcFCnGhl_QHMG5GxY0itoFSF72gKAd-rpy9M,46758
|
|
3
|
-
github_backup-0.44.0.data/scripts/github-backup,sha256=UXvwQ9ouaV6W_jXSgF_4WitYB3nbwwDjdSrDFiaLogM,1533
|
|
4
|
-
github_backup-0.44.0.dist-info/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
|
|
5
|
-
github_backup-0.44.0.dist-info/METADATA,sha256=4z_7Wj4Wtcfzt0hhKnWj48UWxqS1tFOKDfqceKXGGLo,18581
|
|
6
|
-
github_backup-0.44.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
7
|
-
github_backup-0.44.0.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
|
|
8
|
-
github_backup-0.44.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
9
|
-
github_backup-0.44.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|