Ejemplo n.º 1
0
 def export_card(cls,card_num):
     from tv.models import Card
     from lib.functions import int_to_4byte_wrapped, list2hex
     data = []
     try:
         card=Card.objects.get(num=card_num)
     except Card.DoesNotExist:
         return data        
     data.extend(int_to_4byte_wrapped((card.num-1)*2))
     data.extend(card.bin_flags)
     data.extend(int_to_4byte_wrapped(card.balance_int or 0))
     #print list2hex(data)
     return data
Ejemplo n.º 2
0
 def __init__(self,card_id):
     from lib.functions import int_to_4byte_wrapped
     BasicPacket.__init__(self)
     self.data.append(0xad)
     from tv.models import Card, CardDigital
     try:
         card=Card.objects.get(num=card_id)
     except Card.DoesNotExist:
         self.data.append(0x01)
     else:
         if card.active:
             self.data.append(0x01)
         else:
             self.data.append(0x01)
         c = CardDigital.objects.count()
         self.data.extend(int_to_4byte_wrapped(c))
         self.data.extend(int_to_4byte_wrapped(card.digital.pk))
         self.data.extend(int_to_4byte_wrapped((card.num-1)*2))
         self.data.extend(card.bin_flags)
         self.data.extend(int_to_4byte_wrapped(card.balance_int or 0))
         self.mk_prefix()
         self.append_crc()
     print
     print "Generating packet for card #%s" % card.num
Ejemplo n.º 3
0
 def export(cls):
     from settings import EXPORT_PATH
     from lib.functions import int_to_4byte_wrapped, list2bin
     from tv.models import CardDigital
     
     f = open('%s/%s' % (EXPORT_PATH,'user.bin'), 'w')
     data = []
     
     c = CardDigital.objects.count()
     data.extend(int_to_4byte_wrapped(c))        
     f.write(list2bin(data))
     
     for cd in CardDigital.objects.all():
         f.write(list2bin(cls.export_card(cd.card.num)))
             
     f.close()        
Ejemplo n.º 4
0
 def bin_balance(self):
     from lib.functions import int_to_4byte_wrapped
     return int_to_4byte_wrapped(self.balance_int)
Ejemplo n.º 5
0
 def bin_balance(self):
     from lib.functions import int_to_4byte_wrapped
     return int_to_4byte_wrapped(self.balance_int)
Ejemplo n.º 6
0
 def bin_card(self):
     from lib.functions import int_to_4byte_wrapped
     return int_to_4byte_wrapped((self.card_id-1)*2)
Ejemplo n.º 7
0
 def bin_id(self):
     from lib.functions import int_to_4byte_wrapped
     return int_to_4byte_wrapped(self.pk)
Ejemplo n.º 8
0
 def bin_card(self):
     from lib.functions import int_to_4byte_wrapped
     return int_to_4byte_wrapped((self.card_id - 1) * 2)
Ejemplo n.º 9
0
 def bin_id(self):
     from lib.functions import int_to_4byte_wrapped
     return int_to_4byte_wrapped(self.pk)