How to use create_timestamp method in tempest

Best Python code snippet using tempest_python

mongo_import_data.py

Source:mongo_import_data.py Github

copy

Full Screen

1#coding=utf82import datetime3import hashlib4import random5import sys6import pymongo7from bson.objectid import ObjectId8MONGO_HOST = '123.56.8.91'9MONGO_PORT = 2701710MONGO_DBNAME = 'iHealth'11MONGO_AUTHDB = 'iHealth'12MONGO_USER = 'admin'13MONGO_PWD = 'admin123'14def MD5(s):15 '''对字符串s进行md5加密,并返回'''16 m = hashlib.md5()17 m.update(s)18 return m.hexdigest()19# 连接数据库20client = pymongo.MongoClient('mongodb://%s:%s@%s:%d/%s'%(MONGO_USER,MONGO_PWD,MONGO_HOST,MONGO_PORT,MONGO_AUTHDB))21# 切换数据库22db = client[MONGO_DBNAME]23# 清除集合24# db.articles.drop()25db.users.drop()26# 获取集合27articles = db.articles28users = db.users29# 插入数据30# 创建md5对象31# m = hashlib.md5()32# 插入 article 集合数据33# 资讯标题:title34# 发布时间:pubdate35# 发布人:username*36# 内容:content37# print '插入 articles 集合数据……'38# article_list = []39# article_list.append({40# 'title' : '跑步时出现这3大信号,一定要当心!可能是猝死前兆!',41# 'category' : '养生常识',42# 'read' : 0,43# 'upvote' : 0,44# 'publisher' : '中华养生网',45# 'publisher_src' : 'http://www.cnys.com/',46# 'href' : 'http://www.cnys.com/zixun/74403.html',47# 'pubdate' : datetime.datetime.now(),48# 'img' : 'http://img.cnys.com/upload/picture/2017/10-19/Z08l2d.gif',49# 'intro' : '''近年全民热跑,马拉松赛事开展得如火如荼。50# 这本是好事,却发生了伤心事——“平常没病没痛”的青壮年,跑着跑着就倒下猝死了。51# ''',52# 'content' : '''53# <div class="reads">54# <p>近年全民热跑,马拉松赛事开展得如火如荼。</p><p>这本是好事,却发生了伤心事——“平常没病没痛”的青壮年,跑着跑着就倒下猝死了。</p><h3><strong>跑步猝死,这是怎么回事?</strong></h3><p>青壮年猝死大多因为心脏的问题——冠心病、心律失常、先天性心脏病等。</p><p>原因:有心脏病,自己却不知道</p><p>运动猝死者多有冠心病,这是运动猝死第一病因,只是他自己不知道。</p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-19/Z08l2d.gif" alt=""></p></center><p>如今冠心病发病年龄大大提前,二三十岁的冠心病患者很多,因为饮食、抽烟、压力方面的原因。</p><p>其中,很多人平时即使有不舒服,也不觉得是心脏问题,更不会去检查,这就留下了运动猝死的隐患。</p><p><strong>信号1: 胸部压迫感+运动后加重</strong></p><p>胸部有压迫感,就是胸闷。它会在运动后(包括快走、上楼梯)以及情绪激动后加重。</p><p>闷,多代表心脏供血不足——给心脏提供血液的冠状动脉出问题了。</p><p>严重胸闷,是冠心病的征兆。若是运动后胸闷缓解了,就不用担心,因为冠心病的胸闷一定不会在运动后减轻。</p><p>另外,跑步时出现胸闷要尽快看医生,别以为休息一下就能好。</p><p>怎么办?</p><p>做活动平板运动试验,各大医院都有。</p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-19/cOCh6Z.jpg" alt=""></p></center><p>在类似跑步机上的仪器上跑步,检测运动时的心率,并记录心电图。</p><p>跑步时间一般不超过10分钟,有专人在旁监护,如果跑的过程中,心脏不舒服了,就会被喊停。</p><p>之后,将跑的时长、跑到多少心率会有不适等指标综合起来,判断心肌是否缺血。</p>55# </div>56# '''57# })58# article_list.append({59# 'title' : '预防腰椎间盘突出,做好这5点!',60# 'category' : '养生常识',61# 'read' : 0,62# 'upvote' : 0,63# 'publisher' : '中华养生网',64# 'publisher_src' : 'http://www.cnys.com/',65# 'href' : 'http://www.cnys.com/xinde/74390.html',66# 'pubdate' : datetime.datetime.now(),67# 'img' : 'http://img.cnys.com/upload/picture/2017/10-19/6FeA8X.jpg',68# 'intro' : '''腰椎间盘突出症是我们的生活中比较常见的一种疾病,对于这样的一种疾病有什么比较好的治疗方法呢?69# ''',70# 'content' : '''71# <div class="reads">72# <p>腰椎间盘突出症是我们的生活中比较常见的一种疾病,对于这样的一种疾病有什么比较好的治疗方法呢?</p><p><strong>1、注意保暖。</strong></p><p>腰部受凉后会诱发、加重腰椎间盘突出。</p><p><strong>2、正确用腰。</strong></p><p>搬抬重物,先做好准备姿势,不要突然用力;搬提重物尽可能双侧用力;弯腰捡东西时候先蹲下等。</p><p><strong>3、避免久坐、适当活动。</strong></p><p>不端正坐姿时,腰椎处于后弯的位置,腰部肌肉韧带均处在紧张状态,腰椎间盘承受的压力增大10倍!坐办公室的亲可以多喝水,然后会尿急上厕所,然后需要再接水,强迫自己时不时就动起来。(亲测有效)</p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-19/6FeA8X.jpg" alt=""></p></center><p><strong>4、少穿高跟鞋。</strong></p><p>高跟鞋使身体的重心相对提高,人体为了稳定重心平衡,腰背部肌肉的张力会重新调整,一直处于紧绷状态,如果已经腰椎间盘突出,基本需要告别穿高跟鞋。</p><p><strong>5、有外伤及时治疗。</strong></p><p>外伤如果治疗不及时可能造成慢性损伤,诱发腰椎间盘突出。我们的小绵羊就是因为长期反复的外力(如绑沙袋)造成轻微损害,又没有及时的治疗,最后造成了永久的损伤。</p>73# </div>74# '''75# })76# article_list.append({77# 'title' : '别说你不信,水果还真能伤牙!',78# 'category' : '养生常识',79# 'read' : 0,80# 'upvote' : 0,81# 'publisher' : '中华养生网',82# 'publisher_src' : 'http://www.cnys.com/',83# 'href' : 'http://www.cnys.com/zixun/74382.html',84# 'pubdate' : datetime.datetime.now(),85# 'img' : 'http://img.cnys.com/upload/picture/2017/10-19/9AKi8Q.jpg',86# 'intro' : '''和蔬菜比起来,广大的人民群众似乎更喜欢水果,主要是因为甜!甜!甜!问题是,水果里的糖会引起蛀牙吗?这绝对是个问题!87# 水果有很多种吃法,主要有新鲜水果、水果罐头、果汁、干果、果脯和果酱等。水果对牙齿好不好,要看怎么吃!88# ''',89# 'content' : '''<div class="reads">90# <p>和蔬菜比起来,广大的人民群众似乎更喜欢水果,主要是因为甜!甜!甜!问题是,水果里的糖会引起蛀牙吗?这绝对是个问题!</p><p>水果有很多种吃法,主要有新鲜水果、水果罐头、果汁、干果、果脯和果酱等。水果对牙齿好不好,要看怎么吃!</p><p align="left"></p><h3><strong>新鲜水果对牙齿好吗?</strong></h3><br><center></center><p>看起来这可能是违反直觉,确实含有很多糖的水果确实对牙齿有好处。但是,新鲜水果只有作为平衡膳食的一部分,才对牙齿有好处。</p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-19/9AKi8Q.jpg" alt=""></p></center><p>如果你整天只吃水果,对牙齿就不是那么好了。当经常吃水果时,比如每天吃17次(真有人这么干!),那么水果就可能引起蛀牙。原因除了水果的糖分外,还有粘在牙齿上未及时清除的水果碎屑。</p><p>然而,如果只是午饭或晚饭后吃一些新鲜水果,没有证据显示水果会引起蛀牙。新鲜水果含有多种维生素,对改善口腔健康有好处。</p><p align="left"></p><h3><strong>水果罐头对牙齿好吗?</strong></h3><br><center></center><p>如今市场上大多数水果罐头,是浸泡在富含糖的浓缩糖浆中的。由于这些添加的糖,水果罐头可能对牙齿非常有害。</p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-19/CNHd0e.jpg" alt=""></p></center><p>在吃水果罐头之前,看看成分表上是否含有糖。大多数水果罐头也会在成分表上说明含有浓缩糖浆或者稀释糖浆。这就说明这些产品含有过量的糖!</p>91# </div>92# '''93# })94# article_list.append({95# 'title' : '头晕眼花失眠健忘都是肾气不足!快用这3个方法给肾打打气!',96# 'category' : '养生常识',97# 'read' : 0,98# 'upvote' : 0,99# 'publisher' : '中华养生网',100# 'publisher_src' : 'http://www.cnys.com/',101# 'href' : 'http://www.cnys.com/zixun/74365.html',102# 'pubdate' : datetime.datetime.now(),103# 'img' : 'http://img.cnys.com/upload/picture/2017/10-18/SH8mQS.jpg',104# 'intro' : '''头昏眼花、视力模糊、还是失眠健忘,你以为是感冒了、发烧了、还是的表示自己老了?其实还有一种可能,那就是肾气不足!105# ''',106# 'content' : '''<div class="reads">107# <p>头昏眼花、视力模糊、还是失眠健忘,你以为是感冒了、发烧了、还是的表示自己老了?其实还有一种可能,那就是肾气不足!</p><h3><strong>那么肾气不足会怎么样</strong></h3><p><strong>第一,便秘</strong></p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-18/SH8mQS.jpg" alt=""></p></center><p>为什么越来越容易便秘?因为老人更容易肾气不足,中医说“肾司二便”,所以便秘、腹泻、小便不利都与肾有关。</p><p>除了便秘之外,肾气不足还会表现为腹泻,一般发生在天亮之前,也称之为“五更泻”。</p><p><strong>第二,发育迟缓</strong></p><p>在中医里有一种说法叫做“肾气不足型五迟”,所谓“五迟”指的是发育迟缓,表现为筋骨软弱、出牙迟、语言迟、坐不稳等。</p><p><strong>第三,耳鸣、精力不济</strong></p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-18/pv4TS9.jpg" alt=""></p></center><p>通常会表现为听力下降、耳鸣、工作效率低、注意了不集中。</p><p><strong>第四,腰酸背痛</strong></p><p>这几乎是所有肾气不足人群的共同症状,尤其在过度劳累之后,腰痛、膝盖酸软会表现得很明显。</p><p><strong>第五,脱发、色斑、黑眼圈</strong></p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-18/zVZkhl.jpg" alt=""></p></center><p>女性关注的外貌问题,也会受到肾气不足的影响,表现为白发增多、头发不再有光泽、出现黑眼圈、黄褐斑,甚至还会伴有月经不调。</p><p><strong>第六,畏寒怕冷、抵抗力差</strong></p><p>肾气不足的女性更容易畏寒怕冷,即使穿得多,在冬季仍然会表现为手脚冰凉、整夜双脚不温暖。也容易感冒、咳嗽。点击蓝字了解更多肾虚小常识:肾阳虚吃什么好 这些廉价食物让你“阳”气十足</p><p><strong>第七,出现睡眠问题</strong></p><center><p align="center"><img src="http://img.cnys.com/upload/picture/2017/10-18/8Fo43X.jpg" alt=""></p></center><p>表现为没精神,还会表现为难以入睡、睡眠质量低、易惊醒、容易烦躁等。此外,肾气不足还会表现为早衰、健忘、食欲不振、乏力、不耐疲劳以及牙齿过早松动。</p>108# </div>109# '''110# })111# res = articles.insert_many(article_list)112# print res113# print ''114# 插入 users 集合数据115# 字段说明:116# # 必填117# 'nickname' : 昵称118# 'email' : 邮箱地址119# 'password' : 密码120# 'sex' : 性别(取值:0-女,1-男)121# 'birthday' : 出生日122# # 选填123# 'name' : 真实姓名124# 'phone' : 手机号125# 'introduction' : 个人介绍126# # 系统自动生成127# 'age' : 年龄128# 'usertype' : 用户类型(取值:0-游客,1-患者,2-医生,3-管理员)129user_list = []130user_list.append({131 # 必填132 'nickname' : '看病的小明',133 'email' : '123456789@qq.com',134 'password' : MD5('123456'),135 'sex' : 1,136 'birthday' : '1994-3-30',137 # 选填138 'name' : '杨英明',139 'phone' : '12345678901',140 'introduction' : '大家好,我是来看病的',141 # 系统自动生成142 'age' : 23,143 'usertype' : 1, 144})145user_list.append({146 # 必填147 'nickname' : '资深医生华仔',148 'email' : '987654321@qq.com',149 'password' : MD5('123456'),150 'sex' : 1,151 'birthday' : '1974-5-30',152 # 选填153 'name' : '李华',154 'phone' : '12345678902',155 'introduction' : '大家好,我会看病',156 # 系统自动生成157 'age' : 43,158 'usertype' : 2, 159})160user_list.append({161 # 必填162 'nickname' : '明天会更好',163 'email' : '987654322@qq.com',164 'password' : MD5('123456'),165 'sex' : 1,166 'birthday' : '1994-1-30',167 # 选填168 'name' : '王大锤',169 'phone' : '12345678903',170 'introduction' : '大家好,我叫王大锤',171 # 系统自动生成172 'age' : 27,173 'usertype' : 1, 174})175res = users.insert_many(user_list)176print res177print ''178"""179# 插入 site 集合数据180print '插入 site 集合数据……'181site = []182site.append({183 'title' : '百度',184 'url' : 'https://www.baidu.com/',185 'desc': '百度搜索引擎',186 'create_timestamp' : datetime.datetime.now(),187 'favorite_this_site' : [],188 'tags' : []189})190site.append({191 'title' : '哔哩哔哩',192 'url' : 'https://www.bilibili.com/',193 'desc': '国内弹幕网站 - B站',194 'create_timestamp' : datetime.datetime.now(),195 'favorite_this_site' : [],196 'tags' : []197})198site.append({199 'title' : 'Github',200 'url' : 'https://github.com/',201 'desc': 'GitHub 是一个面向开源及私有软件项目的托管平台',202 'create_timestamp' : datetime.datetime.now(),203 'favorite_this_site' : [],204 'tags' : []205})206site.append({207 'title' : 'Readfree',208 'url' : 'http://readfree.me/',209 'desc': '一个 kindle 电子书资源站',210 'create_timestamp' : datetime.datetime.now(),211 'favorite_this_site' : [],212 'tags' : []213})214site.append({215 'title' : '知乎',216 'url' : 'https://www.zhihu.com/',217 'desc': '知乎- 与世界分享你的知识、经验和见解',218 'create_timestamp' : datetime.datetime.now(),219 'favorite_this_site' : [],220 'tags' : []221})222site.append({223 'title' : '博客园',224 'url' : 'https://www.cnblogs.com/',225 'desc': '博客园 - 代码改变世界',226 'create_timestamp' : datetime.datetime.now(),227 'favorite_this_site' : [],228 'tags' : []229})230site.append({231 'title' : 'Google',232 'url' : 'https://www.google.com/',233 'desc': '谷歌搜索 - 全球最大的搜索引擎',234 'create_timestamp' : datetime.datetime.now(),235 'favorite_this_site' : [],236 'tags' : []237})238site.append({239 'title' : '网易云音乐',240 'url' : 'http://music.163.com/',241 'desc': '网易云音乐 - 分享你的音乐',242 'create_timestamp' : datetime.datetime.now(),243 'favorite_this_site' : [],244 'tags' : []245})246site.append({247 'title' : '王垠 - 当然我在扯淡',248 'url' : 'http://www.yinwang.org/',249 'desc': '王垠的博客',250 'create_timestamp' : datetime.datetime.now(),251 'favorite_this_site' : [],252 'tags' : []253})254site.append({255 'title' : '书荒部落',256 'url' : 'https://noveless.com/',257 'desc': '书荒部落',258 'create_timestamp' : datetime.datetime.now(),259 'favorite_this_site' : [],260 'tags' : []261})262site.append({263 'title' : 'AcFun',264 'url' : 'http://www.acfun.cn/',265 'desc': 'AcFun - 认真你就输啦',266 'create_timestamp' : datetime.datetime.now(),267 'favorite_this_site' : [],268 'tags' : []269})270site.append({271 'title' : '呓语 - 杨英明的个人博客',272 'url' : 'http://www.yangyingming.com/',273 'desc': '专注于c++、Python,欢迎交流',274 'create_timestamp' : datetime.datetime.now(),275 'favorite_this_site' : [],276 'tags' : []277})278site.append({279 'title' : '新浪微博',280 'url' : 'http://weibo.com',281 'desc': '新浪微博 - show 出你的生活',282 'create_timestamp' : datetime.datetime.now(),283 'favorite_this_site' : [],284 'tags' : []285})286site.append({287 'title' : '优酷',288 'url' : 'http://www.youku.com/',289 'desc': '视频服务平台,提供视频播放,视频发布',290 'create_timestamp' : datetime.datetime.now(),291 'favorite_this_site' : [],292 'tags' : []293})294site.append({295 'title' : '爱奇艺',296 'url' : 'http://www.iqiyi.com/',297 'desc': '全球领先的提供海量、优质、高清的网络视频服务的大型视频网站',298 'create_timestamp' : datetime.datetime.now(),299 'favorite_this_site' : [],300 'tags' : []301})302# 初始化每个站点的用户收藏列表303print '初始化每个站点的用户收藏列表……'304for i in range(len(site)):305 for j in range(10): # 每个站没多少人收藏306 user_no = int(random.random()*len(user))307 print '站点 %s 被用户 %s 收藏'%(site[i]['title'],users.find()[user_no]['nickname'].encode('utf8'))308 site[i]['favorite_this_site'].append(users.find()[user_no]['_id'])309res = sites.insert_many(site)310print res311print ''312# 插入 tag 集合数据313print '插入 tag 集合数据……'314tag = []315tag.append({316 'title' : '搜索引擎',317 'create_timestamp' : datetime.datetime.now()318 })319tag.append({320 'title' : '弹幕网站',321 'create_timestamp' : datetime.datetime.now()322 })323tag.append({324 'title' : 'ACG',325 'create_timestamp' : datetime.datetime.now()326 })327tag.append({328 'title' : '视频',329 'create_timestamp' : datetime.datetime.now()330 })331tag.append({332 'title' : '开源社区',333 'create_timestamp' : datetime.datetime.now()334 })335tag.append({336 'title' : '社交',337 'create_timestamp' : datetime.datetime.now()338 })339tag.append({340 'title' : '程序员',341 'create_timestamp' : datetime.datetime.now()342 })343tag.append({344 'title' : '资源',345 'create_timestamp' : datetime.datetime.now()346 })347tag.append({348 'title' : '电子书',349 'create_timestamp' : datetime.datetime.now()350 })351tag.append({352 'title' : '问答社区',353 'create_timestamp' : datetime.datetime.now()354 })355tag.append({356 'title' : '博客',357 'create_timestamp' : datetime.datetime.now()358 })359tag.append({360 'title' : '音乐',361 'create_timestamp' : datetime.datetime.now()362 })363# 向 mongo 插入数据364res = tags.insert_many(tag)365print res366print ''367print '初始化每个网站的标签列表……'368def siteAppendTag(site_name,*tag_name_list):369 '''为找到的第一个匹配网站标签列表中添加标签'''370 for tag_name in tag_name_list:371 item = sites.find({'title':site_name})[0]372 if tags.find({'title':tag_name})[0]['_id'] in item['tags']:373 # 该网站已经添加过该标签了374 continue375 item['tags'].append(tags.find({'title':tag_name})[0]['_id'])376 sites.save(item)377siteAppendTag('百度','搜索引擎')378siteAppendTag('哔哩哔哩','弹幕网站','ACG','视频')379siteAppendTag('Github','开源社区','社交','程序员')380siteAppendTag('Readfree','资源','电子书')381siteAppendTag('知乎','问答社区','社交')382siteAppendTag('博客园','博客')383siteAppendTag('Google','搜索引擎')384siteAppendTag('网易云音乐','音乐','社交')385siteAppendTag('王垠 - 当然我在扯淡','博客')386siteAppendTag('书荒部落','资源')387siteAppendTag('AcFun','弹幕网站','ACG','视频')388siteAppendTag('呓语 - 杨英明的个人博客','博客')389siteAppendTag('新浪微博','社交')390siteAppendTag('优酷','视频','社交')391siteAppendTag('爱奇艺','视频','社交')392# 列出热门标签393for tag in tags.find():394 print '标签 %s 被标记过 %d 次'%(tag['title'].encode('utf8'),sites.find({'tags':tag['_id']}).count())395# 列出每个站被多少人收藏过396for site in sites.find():397 print '网站 %s 被 %d 人收藏过'%(site['title'].encode('utf8'),len(site['favorite_this_site']))...

Full Screen

Full Screen

0008_auto_20210603_0950.py

Source:0008_auto_20210603_0950.py Github

copy

Full Screen

1# Generated by Django 3.1.6 on 2021-06-03 07:502from django.conf import settings3from django.db import migrations, models4import django.db.models.deletion5import django_currentuser.db.models.fields6import django_currentuser.middleware7class Migration(migrations.Migration):8 dependencies = [9 migrations.swappable_dependency(settings.AUTH_USER_MODEL),10 ('train_management', '0007_merge_20210530_1920'),11 ]12 operations = [13 migrations.AddField(14 model_name='availability',15 name='create_timestamp',16 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),17 ),18 migrations.AddField(19 model_name='availability',20 name='create_user',21 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_availabilitys', to=settings.AUTH_USER_MODEL),22 ),23 migrations.AddField(24 model_name='availability',25 name='update_timestamp',26 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),27 ),28 migrations.AddField(29 model_name='availability',30 name='update_user',31 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_availabilitys', to=settings.AUTH_USER_MODEL),32 ),33 migrations.AddField(34 model_name='copyrecipient',35 name='create_timestamp',36 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),37 ),38 migrations.AddField(39 model_name='copyrecipient',40 name='create_user',41 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_copyrecipients', to=settings.AUTH_USER_MODEL),42 ),43 migrations.AddField(44 model_name='copyrecipient',45 name='update_timestamp',46 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),47 ),48 migrations.AddField(49 model_name='copyrecipient',50 name='update_user',51 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_copyrecipients', to=settings.AUTH_USER_MODEL),52 ),53 migrations.AddField(54 model_name='dayplanning',55 name='create_timestamp',56 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),57 ),58 migrations.AddField(59 model_name='dayplanning',60 name='create_user',61 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_dayplannings', to=settings.AUTH_USER_MODEL),62 ),63 migrations.AddField(64 model_name='dayplanning',65 name='update_timestamp',66 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),67 ),68 migrations.AddField(69 model_name='dayplanning',70 name='update_user',71 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_dayplannings', to=settings.AUTH_USER_MODEL),72 ),73 migrations.AddField(74 model_name='dayplanningtext',75 name='create_timestamp',76 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),77 ),78 migrations.AddField(79 model_name='dayplanningtext',80 name='create_user',81 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_dayplanningtexts', to=settings.AUTH_USER_MODEL),82 ),83 migrations.AddField(84 model_name='dayplanningtext',85 name='update_timestamp',86 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),87 ),88 migrations.AddField(89 model_name='dayplanningtext',90 name='update_user',91 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_dayplanningtexts', to=settings.AUTH_USER_MODEL),92 ),93 migrations.AddField(94 model_name='dvzofunction',95 name='create_timestamp',96 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),97 ),98 migrations.AddField(99 model_name='dvzofunction',100 name='create_user',101 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_dvzofunctions', to=settings.AUTH_USER_MODEL),102 ),103 migrations.AddField(104 model_name='dvzofunction',105 name='update_timestamp',106 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),107 ),108 migrations.AddField(109 model_name='dvzofunction',110 name='update_user',111 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_dvzofunctions', to=settings.AUTH_USER_MODEL),112 ),113 migrations.AddField(114 model_name='mileage',115 name='create_timestamp',116 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),117 ),118 migrations.AddField(119 model_name='mileage',120 name='create_user',121 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_mileages', to=settings.AUTH_USER_MODEL),122 ),123 migrations.AddField(124 model_name='mileage',125 name='update_timestamp',126 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),127 ),128 migrations.AddField(129 model_name='mileage',130 name='update_user',131 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_mileages', to=settings.AUTH_USER_MODEL),132 ),133 migrations.AddField(134 model_name='personnel',135 name='create_timestamp',136 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),137 ),138 migrations.AddField(139 model_name='personnel',140 name='create_user',141 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_personnels', to=settings.AUTH_USER_MODEL),142 ),143 migrations.AddField(144 model_name='personnel',145 name='update_timestamp',146 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),147 ),148 migrations.AddField(149 model_name='personnel',150 name='update_user',151 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_personnels', to=settings.AUTH_USER_MODEL),152 ),153 migrations.AddField(154 model_name='phonenumber',155 name='create_timestamp',156 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),157 ),158 migrations.AddField(159 model_name='phonenumber',160 name='create_user',161 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_phonenumbers', to=settings.AUTH_USER_MODEL),162 ),163 migrations.AddField(164 model_name='phonenumber',165 name='update_timestamp',166 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),167 ),168 migrations.AddField(169 model_name='phonenumber',170 name='update_user',171 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_phonenumbers', to=settings.AUTH_USER_MODEL),172 ),173 migrations.AddField(174 model_name='reservation',175 name='create_timestamp',176 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),177 ),178 migrations.AddField(179 model_name='reservation',180 name='create_user',181 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_reservations', to=settings.AUTH_USER_MODEL),182 ),183 migrations.AddField(184 model_name='reservation',185 name='update_timestamp',186 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),187 ),188 migrations.AddField(189 model_name='reservation',190 name='update_user',191 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_reservations', to=settings.AUTH_USER_MODEL),192 ),193 migrations.AddField(194 model_name='route',195 name='create_timestamp',196 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),197 ),198 migrations.AddField(199 model_name='route',200 name='create_user',201 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_routes', to=settings.AUTH_USER_MODEL),202 ),203 migrations.AddField(204 model_name='route',205 name='update_timestamp',206 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),207 ),208 migrations.AddField(209 model_name='route',210 name='update_user',211 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_routes', to=settings.AUTH_USER_MODEL),212 ),213 migrations.AddField(214 model_name='station',215 name='create_timestamp',216 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),217 ),218 migrations.AddField(219 model_name='station',220 name='create_user',221 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_stations', to=settings.AUTH_USER_MODEL),222 ),223 migrations.AddField(224 model_name='station',225 name='update_timestamp',226 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),227 ),228 migrations.AddField(229 model_name='station',230 name='update_user',231 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_stations', to=settings.AUTH_USER_MODEL),232 ),233 migrations.AddField(234 model_name='train',235 name='create_timestamp',236 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),237 ),238 migrations.AddField(239 model_name='train',240 name='create_user',241 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_trains', to=settings.AUTH_USER_MODEL),242 ),243 migrations.AddField(244 model_name='train',245 name='update_timestamp',246 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),247 ),248 migrations.AddField(249 model_name='train',250 name='update_user',251 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_trains', to=settings.AUTH_USER_MODEL),252 ),253 migrations.AddField(254 model_name='trainconfiguration',255 name='create_timestamp',256 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),257 ),258 migrations.AddField(259 model_name='trainconfiguration',260 name='create_user',261 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_trainconfigurations', to=settings.AUTH_USER_MODEL),262 ),263 migrations.AddField(264 model_name='trainconfiguration',265 name='update_timestamp',266 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),267 ),268 migrations.AddField(269 model_name='trainconfiguration',270 name='update_user',271 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_trainconfigurations', to=settings.AUTH_USER_MODEL),272 ),273 migrations.AddField(274 model_name='traintimetable',275 name='create_timestamp',276 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),277 ),278 migrations.AddField(279 model_name='traintimetable',280 name='create_user',281 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_traintimetables', to=settings.AUTH_USER_MODEL),282 ),283 migrations.AddField(284 model_name='traintimetable',285 name='update_timestamp',286 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),287 ),288 migrations.AddField(289 model_name='traintimetable',290 name='update_user',291 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_traintimetables', to=settings.AUTH_USER_MODEL),292 ),293 migrations.AddField(294 model_name='traintimetabletemplate',295 name='create_timestamp',296 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),297 ),298 migrations.AddField(299 model_name='traintimetabletemplate',300 name='create_user',301 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_traintimetabletemplates', to=settings.AUTH_USER_MODEL),302 ),303 migrations.AddField(304 model_name='traintimetabletemplate',305 name='update_timestamp',306 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),307 ),308 migrations.AddField(309 model_name='traintimetabletemplate',310 name='update_user',311 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_traintimetabletemplates', to=settings.AUTH_USER_MODEL),312 ),313 migrations.AddField(314 model_name='vehicle',315 name='create_timestamp',316 field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='create_timestamp'),317 ),318 migrations.AddField(319 model_name='vehicle',320 name='create_user',321 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='created_vehicles', to=settings.AUTH_USER_MODEL),322 ),323 migrations.AddField(324 model_name='vehicle',325 name='update_timestamp',326 field=models.DateTimeField(auto_now=True, null=True, verbose_name='update_timestamp'),327 ),328 migrations.AddField(329 model_name='vehicle',330 name='update_user',331 field=django_currentuser.db.models.fields.CurrentUserField(default=django_currentuser.middleware.get_current_authenticated_user, null=True, on_delete=django.db.models.deletion.CASCADE, on_update=True, related_name='updated_vehicles', to=settings.AUTH_USER_MODEL),332 ),...

Full Screen

Full Screen

report.py

Source:report.py Github

copy

Full Screen

...26 print ("Successfully created the directory %s" % self.file_path)27 def begin(self):28 temp = ""29 self.text_to_print = ""30 #st = self.create_timestamp()31 st = ""32 temp += self.append(str(st)+"Date"+","+"Current"+","+"Voltage"+","+"Temperature"+","+"Amper/Hour"+","+"Amper Acu."+","+"Step"+","+"Step State"+","+"Time"+","+"Current Time"+","+"Total Time"+","+"Status\r\n")33 #temp += self.append(str(st)+" **************************************************************************\r\n")34 #st = self.create_timestamp()35 #temp += self.append(str(st)+" ****************************** REPORT BEGIN ******************************\r\n")36 #st = self.create_timestamp()37 ltext = 7438 lsn = len(self.address_number)+639 spaces = (ltext-lsn)/240 remBanner = (ltext-lsn)%241 strBanner = ""42 strFillBanner = ""43 #for n in range(0,int(spaces)):44 # strBanner+="*"45 #for n in range(0,int(remBanner)):46 # strFillBanner+="*"47 #temp += self.append(str(st)+" "+strBanner+" SN: ")48 #temp += self.append(self.address_number + " ")49 #temp += self.append(strBanner+strFillBanner+"\r\n")50 #st = self.create_timestamp()51 #temp += self.append(str(st)+" **************************************************************************\r\n")52 self.text_to_print += temp53 return temp54 55 def end(self):56 temp = ""57 st = self.create_timestamp()58 temp += self.append(str(st)+" **************************************************************************\r\n")59 st = self.create_timestamp()60 temp += self.append(str(st)+" ******************************* REPORT END *******************************\r\n")61 st = self.create_timestamp()62 temp += self.append(str(st)+" **************************************************************************\r\n\r\n")63 self.text_to_print += temp64 return temp65 66 def append(self, text):67 if self.address_number == None:68 raise Exception("IndividualReportError", "No Serial Number as FileName was Assigned!")69 if os.path.isfile(self.file_name): # if file exists70 file = open(self.file_name, "a+") # we append71 file.write(text)72 file.close()73 else:74 file = open(self.file_name, "w+") # we create a new file75 file.write(text)76 file.close()77 return text78 79 def appendWithTimeStamp(self, text):80 if self.address_number == None:81 raise Exception("IndividualReportError", "No Serial Number as FileName was Assigned!")82 st = self.create_timestamp()83 temp = str(st)+" "+ text + "\r\n"84 self.append(temp)85 self.text_to_print += temp86 return temp87 88 def appendWithTimeStampUsingFile(self, text, file):89 if not StringUtils.isNoneOrEmpty(file):90 self.address_number = file91 self.file_name = self.file_path + self.address_number + '.xls' #'.txt'92 if not os.path.exists(self.file_name):93 self.begin()94 st = self.create_timestamp()95 temp = str(st)+" "+ text + "\r\n"96 self.append(temp)97 self.text_to_print += temp98 return temp99 def create_timestamp(self):100 now = datetime.now()101 st = now.strftime('%Y-%m-%d %H:%M:%S') #+ ('.%04d' % (now.microsecond / 100))102 #print(st)103 return st104 def print(self):105 return self.text_to_print106class MainReport:107 home = str(Path.home())108 #if appsettings.useDesktopToSaveReports:109 file_path = home +'/TestLogs/'110 #else:111 #file_path = os.getcwd() + '/TestLogs/'112 file_name = None113 address_number = None114 date_created = None115 date_modified = None116 text_to_print = ""117 def __init__(self):118 try:119 os.makedirs(self.file_path)120 except OSError:121 print ("Creation of the directory %s failed" % self.file_path)122 else:123 print ("Successfully created the directory %s" % self.file_path)124 self.file_name = self.file_path+'mainlog.txt'125 self.text_to_print = ""126 def begin(self):127 temp = ""128 self.text_to_print = ""129 st = self.create_timestamp()130 temp += self.append(str(st)+" **************************************************************************\r\n")131 st = self.create_timestamp()132 temp += self.append(str(st)+" **************************** MAIN REPORT BEGIN ***************************\r\n")133 st = self.create_timestamp()134 temp += self.append(str(st)+" **************************************************************************\r\n")135 self.text_to_print += temp136 return temp137 def end(self):138 temp = ""139 st = self.create_timestamp()140 temp += self.append(str(st)+" **************************************************************************\r\n")141 st = self.create_timestamp()142 temp += self.append(str(st)+" ***************************** MAIN REPORT END ****************************\r\n")143 st = self.create_timestamp()144 temp += self.append(str(st)+" **************************************************************************\r\n\r\n")145 self.text_to_print += temp146 return temp147 def append(self, text):148 if os.path.isfile(self.file_name): # if file exists149 file = open(self.file_name, "a+") # we append150 file.write(text)151 file.close()152 else:153 file = open(self.file_name, "w+") # we create a new file154 file.write(text)155 file.close()156 return text157 def appendWithTimeStamp(self, text):158 st = self.create_timestamp()159 temp = str(st)+" "+text + "\r\n"160 self.append(temp)161 self.text_to_print += temp162 return temp163 def create_timestamp(self):164 now = datetime.now()165 st = now.strftime('%Y-%m-%d %H:%M:%S') + ('.%04d' % (now.microsecond / 100))166 #print(st)167 return st168 def print(self):169 return self.text_to_print170if __name__ == '__main__':171 print("report demo")172 #mreport = MainReport()173 #mreport.begin()174 #mreport.end()175 #ireport = [None, None, None]176 177 ireport = IndividualReport()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful