-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsandbox00.py
413 lines (257 loc) · 11.7 KB
/
sandbox00.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
from re import RegexFlag
RegexFlag
child\.(\w*)
child['$1']
def loopchildren(part,qty,reflist,level=""):
i=0
for line in part.bom:
i+=1
# print(line.part)
branchqty=line['qty']*qty
bomqty=line['qty']
if i<10:
reflevel=level+".0"+str(i)
else:
reflevel=level+"."+str(i)
reflist.append([line['part'],branchqty,bomqty,reflevel])
if len(line['part']['bom'])>0 and (not consume) and (not line['part'].hasConsumingProcess()):
loopchildren(line['part'],branchqty,reflist,level=reflevel)
# else:
# reflist.append((child['part'],branchqty))
# if len(self['bom'])>0 and (not consume) and ( not self.hasConsumingProcess()):
loopchildren(self,qty,reflist,level=level)
{ datasheet: { $exists: true, $ne:"",$regex:".png"},partnumber:{$regex:"OEM"}}
function () {
var dataTable = $('#treetable').DataTable()
dataTable.rows().select();
}
{ edrpath: { $exists: true}}
"id": "1",
"jobnumber": "keksieskdo",
"description": "dkdieksdoies",
"customer": "keksieskdo",
"user_id": "1",
"date_create": "2022-01-02 08:08:34.750696",
"date_due": " ",
"date_modify": " ",
"date_finish": " ",
"(?<oo>[a-zA-Z0-9_]+)": "(?<foo>[a-zA-Z0-9- :.]+)",
$1=StringField( $2 )
id=StringField( )
jobnumber=StringField( )
description=StringField( )
customer=StringField( )
user_id=StringField( )
date_create=StringField( )
date_due=StringField( )
date_modify=StringField( )
date_finish=StringField( )
(?<foo>"[.a-zA-Z0-9_-]+"):(?<o>"[,+-.a-zA-Z0-9_ ]+"),
$1['$2']
show dbs
use TinyMRP
db.part.deleteMany({ partnumber: RegExp('TMRP')})
allparts=mongoPart.objects()
paco=allparts(partnumber="AWS-A-010174")[0]
paco.updateFileset()
pepo=mongoFileSet(description="test")
allparts=mongoPart.objects()
for part in allparts: part.updateFileset()
allparts=mongoPart.objects()
for part in allparts:
part.fileset=None
part.save()
allparts=mongoPart.objects()
paco=allparts(partnumber="200366-GA")[0]
test['children']
paco.get_components()
import pymongo
import csv
client = pymongo.MongoClient("localhost", 27017)
db=client.TinyMRP
partcol=db["part"]
for part in partcol.find():
partcol.update_one({"_id":part["_id"]},{"$unset":{"id":""}})
allparts=mongoPart.objects()
paco=allparts(partnumber="AWS-A-010174")[0]
parents=paco.getparents()
children=paco.getchildren()
pepe=allparts(partnumber="AWS-A-010176")[0]
paco.hasProcess("purchase")
paco.hasProcess("machine")
paco.hasConsumingProcess()
testpart=allparts[1]
testpart.getparents()
test=partcol.find_one({'partnumber':"OEM-TNM10W"})
parents=partcol.find({'children':{ '$elemMatch' :{'pk':test.pk}}})
test=mongoPart().objects(partnumber="OEM-TNM10W")
test=partcol.find({'pk':{'$in:'}})
allparts(description__icontains="bean")
allparts=allparts(Q(description__icontains="bean") & Q( description__icontains="pro"))
pipeline = [ {"$match": {}},
{"$out": "part"},
]
mongodb.destination_collection.aggregate(pipeline)
sudo kill -9 $(sudo lsof -t -i:5000)
allparts=mongoPart.objects()
i=1
for part in allparts:
if i<4500:
i=i+1
part.delete()
part.save()
allparts=mongoPart.objects()
i=1
for part in allparts:
part.delete()
part.save()
def updateFileset(self,web=False,persist=False):
self.get_tag()
parttag=self.partnumber+"_REV_"+self.revision
save=False
fileset=[]
for filetype in config['FILES_CONF'].keys():
if config['FILES_CONF'][filetype]['list']=='yes':
refdict=config['FILES_CONF'][filetype]
refdict['filetype']=filetype
fileset.append(refdict)
filepairs=[]
for filetype in fileset:
if filetype['filetype'] in filelist:
for i in range(6):
extension="extension"+str(i)
# print(type(filetype[extension]))
# print([filetype['filetype'],filetype['folder'],filetype[extension]])
if filetype[extension]!="" and type(filetype[extension])==str:
filepairs.append([filetype['filetype'],filetype['folder'],filetype[extension],filetype['filemod']])
for filetype,folder,extension,filemod in filepairs:
filetag=config['DELIVERABLES'][filetype]['path']+parttag+str(config['DELIVERABLES'][filetype]['filemod'])+"."+extension
if file_exists(filetag):
if config['DELIVERABLES'][filetype]['list']!="yes":
# try:
if self[filetype+'path']!=filetag:
self[filetype+'path']=filetag
# #print(filetype,extension)
# #print("string- " ,filetag)
save=True
# except:
# #print("couldnt save - ", "string- " ,filetag)
# pass
# else:
# if self[filetype+'path']==[] or self[filetype+'path']==None:
# self[filetype+'path']=[]
# if not ( filetag in self[filetype+'path'] ):
# try:
# self[filetype+'path'].append(filetag)
# # #print(filetype,extension)
# # #print("list- ", filetag)
# save=True
# except:
# pass
# # print("issues finding tag for ",self[filetype+'path'])
else:
if filetype=='qr':
qrcode=qr_code(self,filename=filetag)
self['qrpath']=qrcode
# print("before qqqqqqqqqrrrrrrrrrr",self['qrpath'])
self.save()
# if filetype+'path'=='pngpath':
# self[filetype+'path']=url_for('static', filename='images/logo.png')
# save=True
if web:
try:
self[filetype+'path']=self[filetype+'path'].replace(fileserver_path,webfileserver)
except:
pass
if self['pngpath']=="" or self['pngpath']==None or self['pngpath']=="/static/images/logo.svg":
self['pngpath']=webfileserver+'/logo.png'
self.save()
# print(self['pngpath'])
if persist:
# print("later qqqqqqqqqrrrrrrrrrr",self['qrpath'])
if save: self.save()
//Extraction of selected rows for fileset compilation
$("#fileset-dt").click(function () {
var dataTable = $('#treetable').DataTable()
var rowsel= dataTable.rows( { selected: true } );
var alldata=[]
var filelist=[]
for (let i = 0; i < fileset.length; i++) {
// console.log( fileset[i]);
var dicto={checkbox:"#"+fileset[i]['filetype']+"_cb"};
var filecheck="#"+fileset[i]['filetype']+"_cb";
var checkcheckbox=document.querySelector(filecheck).checked;
if( checkcheckbox == true ){filelist.push(fileset[i]['filetype'])}
}
rowsel.data(1).each( function () {
alldata=[];
$(this).each( function () {alldata.push($(this)[0]) } );
} );
$.ajax({
type: "POST",
url: '/vault/api/listfileset',
dataType: "json",
data: {'alldata':testdata, 'filelist':fileout},
success: function(response) {
if( response != "" ){
window.location = response;}
else{alert("No parts or files selected to extract")}},
error: function(error) {
console.log(error)
}
});
});
<a href="/vault/part/detail/quick:AWS-Z-009404_rev_%2525"><img src='http://192.168.1.21:8888/Deliverables/png/AWS-Z-009404_REV_.png' width=auto height=30rm></a>.
{
text: "Toggle Top level only/full BOM",
action: function() {
if (level == "yes") {
level = "no";
document.getElementById("level").innerHTML = "TOP LEVEL ONLY";
document.getElementById("level").style.background = "green";
} else {
level = "yes";
document.getElementById("level").innerHTML = "FULL BOM";
document.getElementById("level").style.background = "orange";
}
$("#treetable").DataTable().ajax.reload();
},
},
{
text: "Toggle Flat/Treee BOM",
action: function() {
if (structure == "tree") {
structure = "flat";
$("#treetable").DataTable().column(0).visible(false);
dataTable.column(8).visible(false);
dataTable.column(9).visible(false);
document.getElementById("structure").innerHTML = "FLAT BOM";
document.getElementById("structure").style.background = "orange";
} else {
structure = "tree";
$("#treetable").DataTable().column(0).visible(true);
dataTable.column(8).visible(true);
dataTable.column(9).visible(true);
document.getElementById("structure").innerHTML = "TREE BOM";
document.getElementById("structure").style.background = "green";
}
$("#treetable").DataTable().ajax.reload();
},
},
{
text: "Toggle Show/Hide Consumed",
action: function() {
console.log(consume);
if (consume == "no") {
consume = "yes";
document.getElementById("consume").innerHTML = "SHOWN";
document.getElementById("consume").style.background = "green";
} else {
consume = "no";
document.getElementById("consume").innerHTML = "HIDDEN";
document.getElementById("consume").style.background = "orange";
}
$("#treetable").DataTable().ajax.reload();
console.log(consume);
},
},