-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgithub-crawler.py
3641 lines (2771 loc) · 101 KB
/
github-crawler.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import github
import time
import datetime
import wget
import db_operation
import DB_NamedUser
import DB_NamedUser_Followship
import DB_Repository
import hashlib
import os
import random
import udload
import DB_Repository_Assignee
import DB_Repository_Contributor
import DB_Repository_Stargazer
import DB_Repository_Subscriber
import DB_Repository_Watcher
import DB_Commit
import DB_GitCommit
import DB_GitCommit_Parentship
import DB_CommitStatus
import DB_Commit_Parentship
import DB_File
import DB_CommitComment
import DB_Branch
import DB_RepositoryLabel
import DB_Repository_Languages
import DB_Milestone
import DB_Milestone_Label
import DB_Issue
import DB_Issue_Label
import DB_IssueComment
import DB_IssueEvent
import DB_PullRequest
import DB_PullRequestPart
import DB_PullRequestComment
import DB_PullRequest_Commit
import DB_Repository_README
import DB_Tag
import DB_Organization
import DB_RepositoryEvent
# enable debug logging for troubleshooting
#github.enable_console_debug_logging()
"""
constants
"""
USER_FOLLOW_LEVEL = 0
NUMBERS_OF_PER_PAGE = 30
"""
global variables
"""
last_stars = 0x7fffffff
start_date = datetime.date(2008, 1, 1)
start_date_week = None
start_date_day = None
g = github.Github("username", "password")
conn = db_operation.connect_to_db_simple()
"""
check if there is no rate remaining, if so, delay the process until
rate limit is reset
"""
def sleep_if_no_rate_remaining():
try:
if g.rate_limiting[0] <= 0:
time.sleep(g.rate_limiting_resettime - time.time())
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
except Exception, e:
print e
"""
Compute hash value of the specified file
...here is sha256...
Parameters:
f, file path, type of string
Return:
hash value if success otherwise None
"""
def hashfile(f, blocksize=65536):
try:
if not os.path.exists(f):
return None
afile = open(f, "rb")
hasher = hashlib.sha256()
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
afile.close()
return hasher.hexdigest()
except Exception as e:
print e
afile.close()
return None
"""
inner method
"""
def wget_download_0(link, filepath):
try:
sleep_if_no_rate_remaining()
wget.download(link, filepath)
return True
except Exception as e:
print e, 'exception'
return False
"""
Download content of the specified link to the specified path with wget
Parameters:
link, url link, type of string
path, local storage path, type of string
Return:
status, True if success otherwise False
"""
def wget_download(link, filepath):
try:
random.seed()
count = 5
while count > 0:
if wget_download_0(link, filepath) and os.path.isfile(filepath):
break
count = count - 1
time.sleep(random.randint(1, 10))
if count > 0:
return True
return False
except Exception as e:
print e
return False
"""
Crawl a file, which is consisted of:
Step1, download content of the specifed link to specified path with wget, if success then Step2
Step2, rename the downloaded file by its hash value and upload to CommonStorage
Step3, remove the download file (i.e. the renamed file)
Parameters:
link, download url link, type of string
path, local storage path, type of string
extension, file extension, type of string
Return:
renamed filename if success otherwise None
"""
def wget_upload_clean(link, extension):
try:
renamed_filename = None
archive_filename = link.split("/")[-1:][0]
# TODO: what to do when download failture
if wget_download(link, archive_filename):
archive_local_url = hashfile(archive_filename)
if archive_local_url is not None:
# rename
archive_local_url = archive_local_url + extension
os.rename(archive_filename, archive_local_url)
# upload to common storage
if udload.upload_to_commonstorage(archive_local_url):
renamed_filename = archive_local_url
# remove
#time.sleep(10)
os.remove(archive_local_url)
return renamed_filename
except Exception as e:
print e
return None
"""
Write content into a new file with specified filename, \
then rename the file by its hash value and upload to CommonStorage, \
then remove the local file
Parameters:
filename, specified name of the new created file, type of basestring
content, content that will be writed into, type of basestring
extension, file extension name, type of basestring
Return:
status, True if success otherwise False
"""
def write_upload_clean(filename, content, extension):
try:
renamed_filename = None
f = open(filename+extension, "wb")
f.write(content)
f.close()
local_url = hashfile(filename+extension)
if local_url is not None:
local_url = local_url + extension
os.rename(filename+extension, local_url)
# upload to common storage
if udload.upload_to_commonstorage(local_url):
renamed_filename = local_url
# remove
#time.sleep(10)
os.remove(local_url)
return renamed_filename
except Exception as e:
print e
return None
"""
Check if the global database connection has been closed, if so, open it again
Parameters:
Return:
status, True if success otherwise False
"""
def open_if_connection_closed():
global conn
try:
if conn is None:
return False
if conn.open == 0:
conn = db_operation.connect_to_db_simple()
if conn is None:
return False
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
except Exception, e:
print e
"""
Process a GitAuthor, which only contains basic info
Parameters:
gitauthor, type of github.GitAuthor.GitAuthor
Return:
status, True if success otherwise False
"""
def process_gitauthor(gitauthor):
try:
print "\t\t\t\tname", gitauthor.name
print "\t\t\t\temail", gitauthor.email
print "\t\t\t\tdate", gitauthor.date
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process a user, crawl its baisc information and relationship information
...baisc info...
...one level followship info...
Parameters:
user, type of github.NamedUser.NamedUser
level, the number of levles, type of int
Return: status, True if success otherwise False
"""
def process_user(user, level):
try:
if user is None:
return True
if open_if_connection_closed() == False:
return False
bio = user.bio
db_nameduser = DB_NamedUser.DB_NamedUser(user, conn)
db_nameduser.save()
if bio is not None:
db_nameduser.update_one("bio", bio.replace("'", "\\'").replace('"', '\\"'))
"""
print "\tUSER", '[id', user.id, '; login: ', user.login, '; email:', user.email, ']'
# basic info
print "\t\ttavatar_url", user.avatar_url
print "\t\tbio", user.bio
print "\t\tblog", user.blog
print "\t\tcollaborators", user.collaborators
print "\t\tcompany", user.company
print "\t\tcontributions", user.contributions
print "\t\tcreated_at", user.created_at
print "\t\tdisk_usage", user.disk_usage
print "\t\temail", user.email
print "\t\tfollowers", user.followers
print "\t\tfollowing", user.following
print "\t\tgravatar_id", user.gravatar_id
print "\t\thireable", user.hireable
print "\t\turl", user.url
print "\t\thtml_url", user.html_url
print "\t\tid", user.id
print "\t\tlogin", user.login
print "\t\tname", user.name
print "\t\tpublic_repos", user.public_repos
print "\t\ttotal_private_repos", user.total_private_repos
print "\t\ttype", user.type
print "\t\tupdated_at", user.updated_at
"""
"""
followship of the specified level
"""
if level <= 0:
return True
# FOLLOWERS
sleep_if_no_rate_remaining()
followers = user.get_followers()
print "\tFOLLOWERS"
for u in followers:
#print '\t\t[id', u.id, '; login:', u.login, '; email:', u.email, ']'
process_user(u, level - 1)
db_nameduser_followship = DB_NamedUser_Followship.DB_NamedUser_Followship(u, user, conn)
db_nameduser_followship.save()
# FOLLOWING
sleep_if_no_rate_remaining()
following = user.get_following()
print "\tFOLLOWING"
for u in following:
#print '\t\t[id', u.id, '; login:', u.login, '; email:', u.email, ']'
process_user(u, level - 1)
db_nameduser_followship = DB_NamedUser_Followship.DB_NamedUser_Followship(user, u, conn)
db_nameduser_followship.save()
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
except Exception, e:
print e
"""
Process a organization, crawl its basic info and relationship info
...basic info...relationship info...
Parameters:
org, type of github.Organization.Organization
Return:
status, True if success otherwise False
"""
def process_organization(org):
try:
if org is None:
return True
if open_if_connection_closed() == False:
return False
db_organization = DB_Organization.DB_Organization(org, conn)
db_organization.save()
"""
print "\t\tavatar_url", org.avatar_url
print "\t\tbilling_email", org.billing_email
print "\t\tblog", org.blog
print "\t\tcollaborators", org.collaborators
print "\t\tcompany", org.company
print "\t\tcreated_at", org.created_at
print "\t\tdisk_usage", org.disk_usage
print "\t\temail", org.email
print "\t\tevents_url", org.events_url
print "\t\tfollowers", org.followers
print "\t\tfollowing", org.following
print "\t\tgravatar_id", org.gravatar_id
print "\t\thtml_url", org.html_url
print "\t\tid", org.id
print "\t\tlocation", org.location
print "\t\tlogin", org.login
print "\t\tmembers_url", org.members_url
print "\t\tname", org.name
print "\t\towned_private_repos", org.owned_private_repos
print "\t\tpublic_members_url", org.public_members_url
print "\t\tpublic_repos", org.public_repos
print "\t\ttotal_private_repos", org.total_private_repos
print "\t\ttype", org.type
print "\t\tupdated_at", org.updated_at
print "\t\turl", org.url
"""
# public members
# GithubException 404 {u'documentation_url': u'https://developer.github.com/v3', u'message': u'Not Found'}
# TODO: consider or not
#sleep_if_no_rate_remaining()
#public_members = org.get_public_members()
#print "\t\tORGANIZATIONPUBLICMEMBERS"
#for member in public_members:
# process_user(member, USER_FOLLOW_LEVEL)
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process a branch, crawl its name and corresponding commit
Parameters:
repo, type of github.Repository.Repository
branch, type of github.Branch.Branch
Return:
status, True if success otherwise False
"""
def process_branch(repo, branch):
try:
if branch is None:
return False
if open_if_connection_closed() == False:
return False
db_branch = DB_Branch.DB_Branch(branch, repo, conn)
db_branch.save()
print '\t[name:', branch.name, '; sha:', branch.commit.sha, ']'
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process branches of one repository
Parameters:
repo, type of github.Repository.Repository
Return:
status, True if success otherwise False
"""
def process_branches(repo):
try:
if repo is None:
return False
sleep_if_no_rate_remaining()
branches = repo.get_branches()
print "\tBRANCHES"
for i in range(0, branches._lenOfFirstPage()):
branch = branches[i]
process_branch(repo, branch)
page = 0
while True:
if branches._couldGrow() == False:
break
branches_per_page = None
sleep_if_no_rate_remaining()
branches_per_page = branches._fetchNextPage()
if branches_per_page is None:
continue
for branch in branches_per_page:
process_branch(repo, branch)
"""
print "\tBRANCHES"
for branch in branches:
process_branch(repo, branch)
"""
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process a CommitComment, crawl its basic info and related author
...basic info and related author...
Parameters:
commit, type of github.Commit.Commit
comment, type of github.CommitComment.CommitComment
Return:
status, True if success otherwise False
"""
def process_commitcomment(commit, comment):
try:
if comment is None:
return False
if open_if_connection_closed() == False:
return False
db_commitcomment = DB_CommitComment.DB_CommitComment(commit, comment, conn)
db_commitcomment.save()
"""
# basic info
print "\t\t\tid", comment.id
print "\t\t\turl", comment.url
print "\t\t\thtml_url", comment.html_url
print "\t\t\tcommit_id", comment.commit_id
print "\t\t\tpath", comment.path
print "\t\t\tline", comment.line
print "\t\t\tposition", comment.position
print "\t\t\tbody [", comment.body, ']'
print "\t\t\tcreated_at", comment.created_at
print "\t\t\tupdated_at", comment.updated_at
"""
# author
author = comment.user
print "\t\t\tCOMMITAUTHOR"
process_user(author, USER_FOLLOW_LEVEL)
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process comments of one commit
Parameters:
commit, type of github.Commit.Commit
Return:
status, True if success otherwise False
"""
def process_commitcomments(commit):
try:
if commit is None:
return False
sleep_if_no_rate_remaining()
comments = commit.get_comments()
for i in range(0, comments._lenOfFirstPage()):
comment = comments[i]
process_commitcomment(commit, comment)
page = 0
while True:
if comments._couldGrow() == False:
break
comments_per_page = None
sleep_if_no_rate_remaining()
comments_per_page = comments._fetchNextPage()
if comments_per_page is None:
continue
for comment in comments_per_page:
process_commitcomment(commit, comment)
"""
print "\t\tCOMMITCOMMENTS"
for comment in comments:
process_commitcomment(commit, comment)
"""
return True
except Exception as e:
print e
return False
"""
Process a CommitFile
Parameters:
f, type of github.File.File
commit, type of github.Commit.Commit
Return:
status, True if success otherwise False
"""
def process_commitfile(f, commit):
try:
if f is None:
return False
if open_if_connection_closed() == False:
return False
db_file = DB_File.DB_File(f, commit, conn)
db_file.save()
"""
print "\t\t\tsha", f.sha
print "\t\t\tfilename", f.filename
print "\t\t\tstatus", f.status
print "\t\t\tadditions", f.additions
print "\t\t\tdeletions", f.deletions
print "\t\t\tchanges", f.changes
print "\t\t\traw_url", f.raw_url
print "\t\t\tblob_url", f.blob_url
print "\t\t\tcontents_url", f.contents_url
#print "\t\t\tpatch [", f.patch, ']'
"""
if f.patch is None:
return True
# patch
print "\t\tpatch"
patch_local_url = write_upload_clean(f.sha, f.patch, ".patch")
if patch_local_url is not None:
db_file.update_one("patch_local_url", patch_local_url)
"""
print "\t\t\tdownloading", (f.sha + '_' + f.filename), '...'
extension = "." + f.filename.split(".")[-1:][0]
raw_local_url = wget_upload_clean(f.raw_url, extension)
if raw_local_url is not None:
db_file.update_one("raw_local_url", raw_local_url)
"""
#wget.download(f.raw_url, f.sha + '_' + f.filename.split("/")[-1:][0])
#print 'done'
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process files related with one commit
Parameters:
commit, type of github.Commit.Commit
Return:
status, True if success otherwise False
"""
def process_commit_files(commit):
try:
if commit is None:
return False
files = commit.files
print "\t\tFILES"
for f in files:
process_commitfile(f, commit)
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process a CommitStatus
...basic info and creator...
Parameters:
status, type of github.CommitStatus.CommitStatus
Return:
status, True if success otherwise False
"""
def process_commitstatus(status, commit):
try:
if status is None:
return False
if open_if_connection_closed() == False:
return False
db_commitstatus = DB_CommitStatus.DB_CommitStatus(status, commit, conn)
db_commitstatus.save()
"""
# basic info
print "\t\t\tid", status.id
print "\t\t\turl", status.url
print "\t\t\ttarget_url", status.target_url
print "\t\t\tdescription", status.description
print "\t\t\tstate", status.state
print "\t\t\tcreated_at", status.created_at
print "\t\t\tupdated_at", status.updated_at
"""
# creator
creator = status.creator
print "\t\t\tcreator"
process_user(creator, USER_FOLLOW_LEVEL)
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process statuses of one commit
Parameters:
commit, type of github.Commit.Commit
Return:
status, True if success otherwise False
"""
def process_commit_statuses(commit):
try:
sleep_if_no_rate_remaining()
statuses = commit.get_statuses()
for i in range(0, statuses._lenOfFirstPage()):
status = commits[i]
process_commitstatus(status, commit)
while True:
if statuses._couldGrow() == False:
break
statuses_per_page = None
sleep_if_no_rate_remaining()
statuses_per_page = statuses._fetchNextPage()
if statuses_per_page is None:
continue
for status in statuses_per_page:
process_commitstatus(status, commit)
"""
print "\t\tCOMMITSTATUS", statuses.totalCount
for status in statuses:
process_commitstatus(status, commit)
"""
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process parent gitcommits of one gitcommit
...crawl all the parent-ship...
Parameters:
child, type of github.GitCommit.GitCommit
parents, type of list of github.GitCommit.GitCommit
Return:
status, True if success otherwise False
"""
def process_gitcommit_parents(child, parents):
try:
if open_if_connection_closed() == False:
return False
for parent in parents:
db_gitcommit_parentship = DB_GitCommit_Parentship.DB_GitCommit_Parentship(parent, child, conn)
db_gitcommit_parentship.save()
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process a gitcommit, a gitcommit is a inside object of a commit
...basic info and parents info...
Parameters:
gitcommit, type of github.GitCommit.GitCommit
Return:
status, True if success otherwise False
"""
def process_gitcommit(gitcommit):
try:
if open_if_connection_closed() == False:
return False
db_gitcommit = DB_GitCommit.DB_GitCommit(gitcommit, conn)
db_gitcommit.save()
"""
# basic info
print "\t\t\tsha", gitcommit.sha
print "\t\t\turl", gitcommit.url
print "\t\t\thtml_url", gitcommit.html_url
print "\t\t\tmessage [", gitcommit.message, ']'
# author and committer
print "\t\t\tGITAUTHOR"
process_gitauthor(gitcommit.author)
process_gitauthor(gitcommit.committer)
"""
# parents ship
parents = gitcommit.parents
print "\t\t\tparents"
process_gitcommit_parents(gitcommit, parents)
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process parent-child relationship between 2 github.Commit.Commit
Parameters:
child, child commit, type of github.Commit.Commit
Return:
status, True if success otherwise False
"""
def process_commit_parents(child):
try:
if child is None:
return False
if open_if_connection_closed() == False:
return False
# 1-level parents ship
parents = child.parents
for parent in parents:
#print "\t\tparent [sha:", parent.sha, ']'
db_commit_parentship = DB_Commit_Parentship.DB_Commit_Parentship(parent, child, conn)
db_commit_parentship.save()
return True
except github.GithubException as ge:
print "GithubException", ge.status, ge.data
return False
except github.BadAttributeException as bae:
print "BadAttributeException", bae.actualValue, bae.exceptedType, bae.transformException
return False
except Exception, e:
print e
return False
"""
Process a commit
......
Parameters:
commit, type of github.Commit.Commit
repo, type of github.Repository.Repository
Return:
status, True if success otherwise False
"""
def process_commit(commit, repo):
try:
#print "\t[sha:", commit.sha, ']'
if open_if_connection_closed() == False: