def deploy(): """Run deployment tasks""" from flask_migrate import upgrade from app.models import Role, Facility, Component, EIISComponentType, CFR, Manufacturer, System upgrade() # insert db data Role.insert_roles() CFR.insert_cfrs() Facility.insert_facilities() System.insert_systems() EIISComponentType.insert_eiiscomponenttypes() ComponentCause.insert_componentcauses() Manufacturer.insert_manufacturers()
def Systems(request): if request.method == "POST": name = request.POST.get("wzna") photo = request.FILES.get("photo") keyword = request.POST.get("key") pa = request.POST.get("path") mi = request.POST.get("neirong") ban = request.POST.get("banquan") bei = request.POST.get("beian") if photo: path = os.path.join(os.getcwd(), 'static\\upload') pathname = os.path.join(path, photo.name) path1 = default_storage.save(pathname, ContentFile(photo.read())) pathname2 = os.path.join('static/upload', photo.name).replace('\\', '/') ss = System(name=name,path=pathname2,keyword=keyword,filepath=pa,nei=mi,ban=ban,bei=bei) ss.save() return render(request,'Systems.html')
def init_system(self): data = get_data(self.excel_unit)['系统'] for system in data: res = System.query.filter_by(system_name=system[0]).first() if res is None: s = System(system_name=system[0]) db.session.add(s) print('系统分类更新完毕')
def create_system(username): form = SystemCreation() if form.validate_on_submit(): system = System(title=form.title.data, descr=form.descr.data, user_id=current_user.id) db.session.add(system) db.session.commit() flash('Congratulations, you have created a new system!') return redirect(url_for('dashboard', username=current_user.username)) return render_template('create_system.html', title='New System', form=form)
def handle(self, *args, **kwargs): Loan.objects.all().delete() Recurrency.objects.all().delete() Transport.objects.all().delete() Driver.objects.all().delete() ItemDelivery.objects.all().delete() Address.objects.all().delete() System.objects.all().delete() sys = System() now_time = utc_to_local(datetime.datetime.now()) sys.last = now_time sys.save() dic_sys = {} dic_sys[sys.type] = sys.timer sys.next = now_time + relativedelta(**dic_sys) sys.save() for i in range(50): transp = Transport() transp.save(first_save=True) driver = Driver() driver.save(first_save=True) idelivr = generate_object_item_delivery() print(idelivr.lat, idelivr.lng)
def UpSystem(self): sys = System.query.filter_by(name=self.data.get('system')).first() if not sys: sys = System(name=self.data.get('system')) self.host.systems = sys
else: # Simplified, really need a message protocol here. # For example, could receive a partial UTF-8 encoded sequence. data = reader.recv(4096) data = data.decode('utf-8') if not data: # No data indicates disconnect #print('disconnected',clients[reader]) to_read.remove(reader) # remove from monitoring del clients[reader] # remove from dict as well else: #print(data) data = data.strip('][').split(', ') system_id, cpu_usage, disk_percent, disk_free, disk_used, os, cpu_cores_phys, cpu_freq_max, memory_total, memory_used, memory_percent = data system_id = system_id.replace("'", "") print(system_id) p = System(os=os, cpu_usage=cpu_usage, system_id=system_id, disk_percent=disk_percent, disk_free=disk_free, disk_used=disk_used, cpu_cores_phys=cpu_cores_phys, cpu_freq_max=cpu_freq_max, memory_total=memory_total, memory_used=memory_used, memory_percent=memory_percent) print(cpu_cores_phys) db.session.add(p) db.session.commit() print('.', flush=True, end='')