def getCommitList(instance, count=30): updateRepo(instance=instance) svn_dir = _getSvnWorkspace(instance) cmd = ['cd %s' % svn_dir, _getSvnCmd('svn log --xml -l %d' % count, instance)] command = ' && '.join(cmd) print("执行命令: %s" % command) recode, data = subprocess.getstatusoutput(command) commit = [] if recode == 0: xml_data = xmltodict.parse(data) try: first = xml_data['log']['logentry'][0] for xml in xml_data['log']['logentry']: print(xml) local_st = utc2local(datetime.datetime.strptime(xml['date'], '%Y-%m-%dT%H:%M:%S.%fZ')) try: commit.append({'id': xml['@revision'], 'date': local_st.strftime('%Y-%m-%d %H:%M:%S'), 'author': xml['author'], 'message': xml['msg'][0:60]}) except TypeError: commit.append({'id': xml['@revision'], 'date': local_st.strftime('%Y-%m-%d %H:%M:%S'), 'author': xml['author'], 'message': xml['msg']}) except KeyError as e: local_st = utc2local(datetime.datetime.strptime(xml_data['log']['logentry']['date'], '%Y-%m-%dT%H:%M:%S.%fZ')) commit.append({'id': xml_data['log']['logentry']['@revision'], 'date': local_st.strftime('%Y-%m-%d %H:%M:%S'), 'author': xml_data['log']['logentry']['author'], 'message': xml_data['log']['logentry']['msg']}) return commit
def _get_version(self): local_st = utc2local(self.instance.created_at) return local_st.strftime('%Y%m%d%H%M%S')
def _generate_version(self): local_st = utc2local(self.created_at) return local_st.strftime('%Y%m%d%H%M%S')
def Version(dt): local_st = utc2local(dt) return local_st.strftime('%Y%m%d-%H%M%S')