-
Notifications
You must be signed in to change notification settings - Fork 11
get from git #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tunglam14
wants to merge
1
commit into
familug:mailauto
Choose a base branch
from
tunglam14:mailauto
base: mailauto
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
get from git #3
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,15 @@ | |
|
|
||
| from datetime import date as dtdate | ||
| from datetime import timedelta | ||
| import urllib | ||
| from xml.dom import minidom | ||
|
|
||
| from pprint import pprint | ||
|
|
||
| # find this token in git.vccloud.vn, "News Feed" item below right column | ||
| GIT_TOKEN = 'c9sArqzmoVMqgy7BUjyh' | ||
|
|
||
| GIT_URL = "http://git.vccloud.vn/dashboard.atom?private_token="+GIT_TOKEN | ||
|
|
||
| """ A simple script auto generate data for | ||
| reporting weekly at BBTeam - VCCloud""" | ||
|
|
@@ -21,8 +30,105 @@ def get_week_boundary(day_in_week=dtdate.today()): | |
| return (mon_of_week.strftime(date_format), | ||
| sat_of_week.strftime(date_format)) | ||
|
|
||
| def send_request(url): | ||
| return urllib.urlopen(url) | ||
|
|
||
| # get data (branch name + commit-content, commit-time) from git | ||
| # lists or json ??? | ||
| # structure: | ||
| # [ | ||
| # [ | ||
| # 'branch name 1', | ||
| # 'updated time 1', | ||
| # [ | ||
| # ['commit content 1','commit time 1'], | ||
| # ['commit content 2','commit time 2'], | ||
| # ['commit content n','commit time n'], | ||
| # ] | ||
| # ], | ||
| # [ | ||
| # 'branch name n', | ||
| # 'updated time n', | ||
| # [ | ||
| # ['commit content 1','commit time 1'], | ||
| # ['commit content 2','commit time 2'], | ||
| # ['commit content n','commit time n'], | ||
| # ] | ||
| # ] | ||
| # ] | ||
|
|
||
| def get_from_git(): | ||
| url = GIT_URL | ||
| res = send_request(url) | ||
| """ parse XML: | ||
| <entry> | ||
| <id>tag:git.vccloud.vn,2013-03-29:878</id> | ||
| <link href="http://git.vccloud.vn/lamdt/vpn/commit/edf2b1ce83f2fa8fdddd5019af958d59870946f9"/> | ||
| <title>LamDT pushed to branch master at vpn</title> | ||
| <updated>2013-03-29T04:30:49Z</updated> | ||
| <media:thumbnail width="40" height="40" url="http://www.gravatar.com/avatar/202e3cd5282ce662ab7dbac73029e545?s=40&d=mm"/> | ||
| <author> | ||
| <name>LamDT</name> | ||
| <email>lamdt@vccloud.vn</email> | ||
| </author> | ||
| <summary type="xhtml"> | ||
| <div xmlns='http://www.w3.org/1999/xhtml'> | ||
| <p> | ||
| <strong>at VCC</strong> | ||
| <a href="/lamdt/vpn/commit/edf2b1ce83f2fa8fdddd5019af958d59870946f9">(#edf2b1ce83f)</a> | ||
| <i>at 2013-03-29 11:30:48</i> | ||
| </p> | ||
| <blockquote><p>button fix for chrome</p></blockquote> | ||
| </div> | ||
| </summary> | ||
| </entry> | ||
| """ | ||
| result = [] | ||
| dom = minidom.parse(res) | ||
| item_list = dom.getElementsByTagName('entry') | ||
|
|
||
| for node in item_list: | ||
| entry = [] | ||
| # get title | ||
| title = node.getElementsByTagName('title') | ||
| entry.append(title[0].firstChild.nodeValue) | ||
|
|
||
| # # get update | ||
| update = node.getElementsByTagName('updated') | ||
| entry.append(update[0].firstChild.nodeValue) | ||
|
|
||
| # get commits | ||
| entry_commits = [] | ||
| commits = node.getElementsByTagName('div') | ||
|
|
||
| for commit in commits: | ||
| entry_commit_one = [] | ||
|
|
||
| # get commit time | ||
| for commit_time in commit.getElementsByTagName('i'): | ||
| # print commit_time.firstChild.nodeValue | ||
| entry_commit_one.append(commit_time.firstChild.nodeValue) | ||
|
|
||
| # get commit content | ||
| for commit_content in commit.getElementsByTagName('p'): | ||
| # print commit_content.firstChild.nodeValue | ||
| entry_commit_one.append(commit_content.firstChild.nodeValue) | ||
|
|
||
| entry_commits.append(entry_commit_one) | ||
|
|
||
| entry.append(entry_commits) | ||
|
|
||
| # result concatenation | ||
| result.append(entry) | ||
|
|
||
| pprint (result) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pprint chỉ để test output thôi, cái này cần trả về 1 kết quả để nhúng vào template . Vậy phải return 1 string nào đó |
||
|
|
||
|
|
||
| def get_subject(wbdr=get_week_boundary()): | ||
| return "Báo cáo tuần (%s -> %s)" % wbdr | ||
| # print get_from_git('c9sArqzmoVMqgy7BUjyh') | ||
| # return "Báo cáo tuần (%s -> %s)" % wbdr | ||
| return get_from_git() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| print get_subject() | ||
| get_subject() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mấy cái này cho xuoóng dưới cái dòng A simple. ..