def call(namespace):
        caller = Caller(verbose=True)
        phone = namespace.phone if namespace.phone is not None else 9023618802
        trunk = namespace.trunk if namespace.trunk is not None else '2'
        phone2 = namespace.phone2 if namespace.phone2 is not None else None

        trunk = decipher(trunk)
        if not trunk:
            print('указан несуществующий транк - ошибка')
            return

        muid = str(uuid.uuid4())
        with TeleDB() as db:
            db << 'INSERT INTO `tele_material` (`intphone`, `region_id`, `extra`, `start_dial`,`trunk_dial`) \
               VALUES (%s,33,2,NOW(),%s)' < (int(phone), muid)
            db << 'SELECT last_insert_id() as id'
            ids = [db.one()['id']]
            if phone2:
                db << 'INSERT INTO `tele_material` (`intphone`, `region_id`, `extra`, `start_dial`,`trunk_dial`) \
                   VALUES (%s,33,2,NOW(),%s)' < (int(phone2), muid)
                db << 'SELECT last_insert_id() as id'
                ids.append(db.one()['id'])

            #import pdb; pdb.set_trace()

            if not caller.produce(db, trunk, ids):
                db << 'UPDATE `tele_material` SET `trunk_dial`=NULL,`start_dial`=NULL WHERE `id` = %s' < muid
 def trunk(namespace):
     #import pdb; pdb.set_trace()
     trunk = decipher(namespace.trunk)
     if not trunk:
         print('указан несуществующий транк - ошибка')
         return
     with TeleDB() as db:
         router = MaterialRouter(db)
         feedstock = router.feedstock(trunk)
         if feedstock and namespace.verbose:
             print('Запас ' + str(len(feedstock)))
         caller = Caller(verbose=namespace.verbose)
         if not caller.produce(db, trunk, feedstock):
             db << 'UPDATE `tele_material` SET `trunk_dial`=NULL,`start_dial`=NULL WHERE `trunk_dial` = %s' < router.uid