def unix(value): if not _convert: _late_import() if isinstance(value, (date, builtin_datetime)): pass elif value < 10000000000: value = _convert.unix2datetime(value) else: value = _convert.milli2datetime(value) return str(_convert.datetime2unix(value))
def datetime(value): if not _convert: _late_import() if isinstance(value, (date, builtin_datetime)): pass elif value < 10000000000: value = _convert.unix2datetime(value) else: value = _convert.milli2datetime(value) return _convert.datetime2string(value, "%Y-%m-%d %H:%M:%S")
def iterator(): try: while True: try: line = proc.stdout.readline() if line == '': proc.wait() if proc.returncode: Log.error("Unable to pull hg log: return code {{return_code}}", { "return_code": proc.returncode }) return except Exception, e: Log.error("Problem getting another line", e) if line.strip() == "": continue Log.note(line) # changeset = "{date|hgdate|urlescape}\t{node}\t{rev}\t{author|urlescape}\t{branches}\t\t\t\t{p1rev}\t{p1node}\t{parents}\t{children}\t{tags}\t{desc|urlescape}\n" # branch = "{branch}%0A" # parent = "{parent}%0A" # tag = "{tag}%0A" # child = "{child}%0A" ( date, node, rev, author, branches, files, file_adds, file_dels, p1rev, p1node, parents, children, tags, desc ) = (urllib.unquote(c) for c in line.split("\t")) file_adds = set(file_adds.split("\n")) - {""} file_dels = set(file_dels.split("\n")) - {""} files = set(files.split("\n")) - set() doc = { "repos": repo.name, "date": convert.unix2datetime(convert.value2number(date.split(" ")[0])), "node": node, "revision": rev, "author": author, "branches": set(branches.split("\n")) - {""}, "file_changes": files - file_adds - file_dels - {""}, "file_adds": file_adds, "file_dels": file_dels, "parents": set(parents.split("\n")) - {""} | {p1rev+":"+p1node}, "children": set(children.split("\n")) - {""}, "tags": set(tags.split("\n")) - {""}, "description": desc } doc = elasticsearch.scrub(doc) yield doc except Exception, e: if isinstance(e, ValueError) and e.message.startswith("need more than "): Log.error("Problem iterating through log ({{message}})", { "message": line }, e) Log.error("Problem iterating through log", e)
def iterator(): try: while True: try: line = proc.stdout.readline() if line == '': proc.wait() if proc.returncode: Log.error( "Unable to pull hg log: return code {{return_code}}", {"return_code": proc.returncode}) return except Exception, e: Log.error("Problem getting another line", e) if line.strip() == "": continue Log.note(line) # changeset = "{date|hgdate|urlescape}\t{node}\t{rev}\t{author|urlescape}\t{branches}\t\t\t\t{p1rev}\t{p1node}\t{parents}\t{children}\t{tags}\t{desc|urlescape}\n" # branch = "{branch}%0A" # parent = "{parent}%0A" # tag = "{tag}%0A" # child = "{child}%0A" (date, node, rev, author, branches, files, file_adds, file_dels, p1rev, p1node, parents, children, tags, desc) = (urllib.unquote(c) for c in line.split("\t")) file_adds = set(file_adds.split("\n")) - {""} file_dels = set(file_dels.split("\n")) - {""} files = set(files.split("\n")) - set() doc = { "repos": repo.name, "date": convert.unix2datetime( convert.value2number(date.split(" ")[0])), "node": node, "revision": rev, "author": author, "branches": set(branches.split("\n")) - {""}, "file_changes": files - file_adds - file_dels - {""}, "file_adds": file_adds, "file_dels": file_dels, "parents": set(parents.split("\n")) - {""} | {p1rev + ":" + p1node}, "children": set(children.split("\n")) - {""}, "tags": set(tags.split("\n")) - {""}, "description": desc } doc = elasticsearch.scrub(doc) yield doc except Exception, e: if isinstance( e, ValueError) and e.message.startswith("need more than "): Log.error("Problem iterating through log ({{message}})", {"message": line}, e) Log.error("Problem iterating through log", e)