From cf4cacd78f39c1b3abe956eef1d317cd65a73403 Mon Sep 17 00:00:00 2001
From: Adhidarma Hadiwinoto <gua@adhisimon.org>
Date: Fri, 11 Mar 2016 16:18:02 +0700
Subject: [PATCH] remove overlimit products

---
 main.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/main.py b/main.py
index e1b315b..9cb9779 100755
--- a/main.py
+++ b/main.py
@@ -5,6 +5,7 @@ from logging.handlers import TimedRotatingFileHandler
 import ConfigParser
 import json
 from os import getpid
+import os
 import re
 import signal
 import sys
@@ -708,6 +709,20 @@ def updateChipInfo(msisdn):
         CHIPINFO = BASE_CHIPINFO + '-' + msisdn
         
     logger.info('CHIPINFO: {0}'.format(CHIPINFO))
+
+def removeOverLimitProducts():
+    global PRODUCTS
+    
+    if os.path.isfile('XL5.deny'):
+        sate24.removeProduct(PRODUCTS, 'XL5')
+        
+    if os.path.isfile('XL10.deny'):
+        sate24.removeProduct(PRODUCTS, 'XL10')
+    
+    if os.path.isfile('ALL.deny'):
+        sate24.removeProduct(PRODUCTS, 'XL5')
+        sate24.removeProduct(PRODUCTS, 'XL10')
+        
         
 def main():
     global logger
@@ -775,6 +790,8 @@ def main():
     checkAccount(modem)
     sleep(5)
     
+    removeOverLimitProducts()
+    
     enablePull()
     
     checkBalance(modem)
-- 
1.9.0