Ejemplo n.º 1
0
 def loadBuffers(self):
   print('Importing buffers...')
   cnt = 0
   starttime = time()
   self.cursor.execute('''
     SELECT name, description, location_id, item_id, onhand,
       minimum, minimum_calendar_id, producing_id, type, leadtime, min_inventory,
       max_inventory, min_interval, max_interval, size_minimum,
       size_multiple, size_maximum, fence, carrying_cost,
       category, subcategory, source
     FROM buffer %s
     ''' % self.filter_where)
   for i in self.cursor.fetchall():
     cnt += 1
     if i[8] == "procure":
       b = frepple.buffer_procure(
         name=i[0], description=i[1], item=frepple.item(name=i[3]), onhand=i[4],
         category=i[19], subcategory=i[20], source=i[21]
         )
       if i[9]:
         b.leadtime = i[9]
       if i[10]:
         b.mininventory = i[10]
       if i[11]:
         b.maxinventory = i[11]
       if i[14]:
         b.size_minimum = i[14]
       if i[15]:
         b.size_multiple = i[15]
       if i[16]:
         b.size_maximum = i[16]
       if i[17]:
         b.fence = i[17]
     elif i[8] == "infinite":
       b = frepple.buffer_infinite(
         name=i[0], description=i[1], item=frepple.item(name=i[3]), onhand=i[4],
         category=i[19], subcategory=i[20], source=i[21]
         )
     elif not i[8] or i[8] == "default":
       b = frepple.buffer(
         name=i[0], description=i[1], item=frepple.item(name=i[3]), onhand=i[4],
         category=i[19], subcategory=i[20], source=i[21]
         )
     else:
       raise ValueError("Buffer type '%s' not recognized" % i[8])
     if i[2]:
       b.location = frepple.location(name=i[2])
     if i[5]:
       b.minimum = i[5]
     if i[6]:
       b.minimum_calendar = frepple.calendar(name=i[6])
     if i[7]:
       b.producing = frepple.operation(name=i[7])
     if i[18]:
       b.carrying_cost = i[18]
     if i[12]:
       b.mininterval = i[12]
     if i[13]:
       b.maxinterval = i[13]
   print('Loaded %d buffers in %.2f seconds' % (cnt, time() - starttime))
Ejemplo n.º 2
0
 def loadBuffers(self):
   print('Importing buffers...')
   cnt = 0
   starttime = time()
   self.cursor.execute('''
     SELECT name, description, location_id, item_id, onhand,
       minimum, minimum_calendar_id, type,
       min_interval, category, subcategory, source
     FROM buffer %s
     ''' % self.filter_where)
   for i in self.cursor.fetchall():
     cnt += 1
     if i[7] == "infinite":
       b = frepple.buffer_infinite(
         name=i[0], description=i[1], location=frepple.location(name=i[2]),
         item=frepple.item(name=i[3]), onhand=i[4],
         category=i[9], subcategory=i[10], source=i[11]
         )
     elif not i[7] or i[7] == "default":
       b = frepple.buffer(
         name=i[0], description=i[1], location=frepple.location(name=i[2]),
         item=frepple.item(name=i[3]), onhand=i[4],
         category=i[9], subcategory=i[10], source=i[11]
         )
       if i[8]:
         b.mininterval = i[8].total_seconds()
     else:
       raise ValueError("Buffer type '%s' not recognized" % i[7])
     if i[11] == 'tool':
       b.tool = True
     if i[5]:
       b.minimum = i[5]
     if i[6]:
       b.minimum_calendar = frepple.calendar(name=i[6])
   print('Loaded %d buffers in %.2f seconds' % (cnt, time() - starttime))
Ejemplo n.º 3
0
 def loadBuffers(self):
   print('Importing buffers...')
   cnt = 0
   starttime = time()
   self.cursor.execute('''
     SELECT name, description, location_id, item_id, onhand,
       minimum, minimum_calendar_id, type,
       min_interval, category, subcategory, source
     FROM buffer %s
     ''' % self.filter_where)
   for i in self.cursor.fetchall():
     cnt += 1
     if i[7] == "infinite":
       b = frepple.buffer_infinite(
         name=i[0], description=i[1], location=frepple.location(name=i[2]),
         item=frepple.item(name=i[3]), onhand=i[4],
         category=i[9], subcategory=i[10], source=i[11]
         )
     elif not i[7] or i[7] == "default":
       b = frepple.buffer(
         name=i[0], description=i[1], location=frepple.location(name=i[2]),
         item=frepple.item(name=i[3]), onhand=i[4],
         category=i[9], subcategory=i[10], source=i[11]
         )
       if i[8]:
         b.mininterval = i[8].total_seconds()
     else:
       raise ValueError("Buffer type '%s' not recognized" % i[7])
     if i[11] == 'tool':
       b.tool = True
     if i[5]:
       b.minimum = i[5]
     if i[6]:
       b.minimum_calendar = frepple.calendar(name=i[6])
   print('Loaded %d buffers in %.2f seconds' % (cnt, time() - starttime))
Ejemplo n.º 4
0
 def loadBuffers(self):
   print('Importing buffers...')
   cnt = 0
   starttime = time()
   self.cursor.execute('''
     SELECT name, description, location_id, item_id, onhand,
       minimum, minimum_calendar_id, producing_id, type, leadtime, min_inventory,
       max_inventory, min_interval, max_interval, size_minimum,
       size_multiple, size_maximum, fence, category, subcategory, source
     FROM buffer %s
     ''' % self.filter_where)
   for i in self.cursor.fetchall():
     cnt += 1
     if i[8] == "procure":
       b = frepple.buffer_procure(
         name=i[0], description=i[1], item=frepple.item(name=i[3]), onhand=i[4],
         category=i[18], subcategory=i[19], source=i[20]
         )
       if i[9]:
         b.leadtime = i[9]
       if i[10]:
         b.mininventory = i[10]
       if i[11]:
         b.maxinventory = i[11]
       if i[14]:
         b.size_minimum = i[14]
       if i[15]:
         b.size_multiple = i[15]
       if i[16]:
         b.size_maximum = i[16]
       if i[17]:
         b.fence = i[17]
     elif i[8] == "infinite":
       b = frepple.buffer_infinite(
         name=i[0], description=i[1], item=frepple.item(name=i[3]), onhand=i[4],
         category=i[18], subcategory=i[19], source=i[20]
         )
     elif not i[8] or i[8] == "default":
       b = frepple.buffer(
         name=i[0], description=i[1], item=frepple.item(name=i[3]), onhand=i[4],
         category=i[18], subcategory=i[19], source=i[20]
         )
     else:
       raise ValueError("Buffer type '%s' not recognized" % i[8])
     if i[20] == 'tool':
       b.tool = True
     if i[2]:
       b.location = frepple.location(name=i[2])
     if i[5]:
       b.minimum = i[5]
     if i[6]:
       b.minimum_calendar = frepple.calendar(name=i[6])
     if i[7]:
       b.producing = frepple.operation(name=i[7])
     if i[12]:
       b.mininterval = i[12]
     if i[13]:
       b.maxinterval = i[13]
   print('Loaded %d buffers in %.2f seconds' % (cnt, time() - starttime))
Ejemplo n.º 5
0
def loadBuffers(cursor):
    print('Importing buffers...')
    cnt = 0
    starttime = time()
    cursor.execute('''SELECT name, description, location_id, item_id, onhand,
     minimum, minimum_calendar_id, producing_id, type, leadtime, min_inventory,
     max_inventory, min_interval, max_interval, size_minimum,
     size_multiple, size_maximum, fence, carrying_cost,
     category, subcategory FROM buffer''')
    for i, j, k, l, m, t, n, o, q, f1, f2, f3, f4, f5, f6, f7, f8, f9, p, r, s in cursor.fetchall(
    ):
        cnt += 1
        if q == "procure":
            b = frepple.buffer_procure(name=i,
                                       description=j,
                                       item=frepple.item(name=l),
                                       onhand=m,
                                       category=r,
                                       subcategory=s)
            if f1: b.leadtime = f1
            if f2: b.mininventory = f2
            if f3: b.maxinventory = f3
            if f4: b.mininterval = f4
            if f5: b.maxinterval = f5
            if f6: b.size_minimum = f6
            if f7: b.size_multiple = f7
            if f8: b.size_maximum = f8
            if f9: b.fence = f9
        elif q == "infinite":
            b = frepple.buffer_infinite(name=i,
                                        description=j,
                                        item=frepple.item(name=l),
                                        onhand=m,
                                        category=r,
                                        subcategory=s)
        elif not q or q == "default":
            b = frepple.buffer(name=i,
                               description=j,
                               item=frepple.item(name=l),
                               onhand=m,
                               category=r,
                               subcategory=s)
        else:
            raise ValueError("Buffer type '%s' not recognized" % q)
        if k: b.location = frepple.location(name=k)
        if t: b.minimum = t
        if n: b.minimum_calendar = frepple.calendar(name=n)
        if o: b.producing = frepple.operation(name=o)
        if p: b.carrying_cost = p
    print('Loaded %d buffers in %.2f seconds' % (cnt, time() - starttime))
Ejemplo n.º 6
0
  def run(cls, database=DEFAULT_DB_ALIAS, **kwargs):
    import frepple

    if cls.filter:
      filter_and = "and %s " % cls.filter
      filter_where = "where %s " % cls.filter
    else:
      filter_and = ""
      filter_where = ""

    with connections[database].chunked_cursor() as cursor:
      cnt = 0
      starttime = time()
      cursor.execute('''
        SELECT name, description, location_id, item_id, onhand,
          minimum, minimum_calendar_id, type,
          min_interval, category, subcategory, source
        FROM buffer %s
        ''' % filter_where)
      for i in cursor:
        cnt += 1
        if i[7] == "infinite":
          b = frepple.buffer_infinite(
            name=i[0], description=i[1], location=frepple.location(name=i[2]),
            item=frepple.item(name=i[3]), onhand=max(i[4] or 0, 0),
            category=i[9], subcategory=i[10], source=i[11]
            )
        elif not i[7] or i[7] == "default":
          b = frepple.buffer(
            name=i[0], description=i[1], location=frepple.location(name=i[2]),
            item=frepple.item(name=i[3]), onhand=max(i[4] or 0, 0),
            category=i[9], subcategory=i[10], source=i[11]
            )
          if i[8]:
            b.mininterval = i[8].total_seconds()
        else:
          raise ValueError("Buffer type '%s' not recognized" % i[7])
        if i[10] == 'tool':
          b.tool = True
        if i[5]:
          b.minimum = i[5]
        if i[6]:
          b.minimum_calendar = frepple.calendar(name=i[6])
      logger.info('Loaded %d buffers in %.2f seconds' % (cnt, time() - starttime))
Ejemplo n.º 7
0
def loadBuffers(cursor):
  print('Importing buffers...')
  cnt = 0
  starttime = time()
  cursor.execute('''SELECT name, description, location_id, item_id, onhand,
     minimum, minimum_calendar_id, producing_id, type, leadtime, min_inventory,
     max_inventory, min_interval, max_interval, size_minimum,
     size_multiple, size_maximum, fence, carrying_cost,
     category, subcategory FROM buffer''')
  for i,j,k,l,m,t,n,o,q,f1,f2,f3,f4,f5,f6,f7,f8,f9,p,r,s in cursor.fetchall():
    cnt += 1
    if q == "procure":
      b = frepple.buffer_procure(
        name=i, description=j, item=frepple.item(name=l), onhand=m,
        category=r, subcategory=s
        )
      if f1: b.leadtime = f1
      if f2: b.mininventory = f2
      if f3: b.maxinventory = f3
      if f4: b.mininterval = f4
      if f5: b.maxinterval = f5
      if f6: b.size_minimum = f6
      if f7: b.size_multiple = f7
      if f8: b.size_maximum = f8
      if f9: b.fence = f9
    elif q == "infinite":
      b = frepple.buffer_infinite(
        name=i, description=j, item=frepple.item(name=l), onhand=m,
        category=r, subcategory=s
        )
    elif not q or q == "default":
      b = frepple.buffer(
        name=i, description=j, item=frepple.item(name=l), onhand=m,
        category=r, subcategory=s
        )
    else:
      raise ValueError("Buffer type '%s' not recognized" % q)
    if k: b.location = frepple.location(name=k)
    if t: b.minimum = t
    if n: b.minimum_calendar = frepple.calendar(name=n)
    if o: b.producing = frepple.operation(name=o)
    if p: b.carrying_cost = p
  print('Loaded %d buffers in %.2f seconds' % (cnt, time() - starttime))