Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/lib/libbasic_operation.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/lib/libbasic_operation.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/lib/libbasic_operation.py	(working copy)
@@ -267,7 +267,7 @@
     return socket.inet_ntoa(fcntl.ioctl(
         s.fileno(),
         0x8915,  # SIOCGIFADDR
-        struct.pack('256s', ifname[:15])
+        struct.pack('256s', ifname[:15].encode('utf-8'))
     )[20:24])
 
 
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/lib/task_scheduler.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/lib/task_scheduler.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/lib/task_scheduler.py	(working copy)
@@ -1322,8 +1322,9 @@
         db = DB.get_connected_db()
         create_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
         # for backup config file, use 'modify_time' to save device name
-        insert_sql = "INSERT INTO file_list(name, create_time, modify_time, type, comment, device_type) values('%s', '%s', '%s', '%s', '%s', '%s')" % (
-            real_file_name, create_time, device_info['name'], 'backup', comment, device_info['type'])
+        file_type_id = 5
+        insert_sql = "INSERT INTO file_list(name, create_time, modify_time, type, file_type_id, comment, device_type) values('%s', '%s', '%s', '%s', '%s', '%s', '%s')" % (
+            real_file_name, create_time, device_info['name'], 'backup', file_type_id, comment, device_info['type'])
         db.execute_sql(insert_sql)
         db.close()
 
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/configuration/config_file/__init__.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/configuration/config_file/__init__.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/configuration/config_file/__init__.py	(working copy)
@@ -23,7 +23,13 @@
 from hive.model.action import Action
 from hive.model.fields import *
 from hive.model.manager import CLIManager
+from hive.model.query import mark_expire_all, mark_expire_one
+from hive.session import get_model
+from hive.exceptions import ModelQueryException
+from hive.model.legacycli import CLICmdError
 
+CUSTOMIZE_FILE_TYPE_ID = 6
+
 __ = _
 """
 class FileType(ANModel):
@@ -335,15 +341,25 @@
             data = db.fetchall(fetchall_sql)
             db.close()
             key = ['name', 'create_time', 'modify_time', 'file_type', 'comment', 'device_type']
-            result = [dict(zip(key, each)) for each in data]
             """
             for each in result:
                 each['asso_file_type'] = [{'name':each['type']}]
                 del each['type']
                 #self._model._meta.mark_delay_query(each)
             """
-            res = sorted(result, key=lambda x: x["create_time"], reverse=True)
-            return QuerySet(self._model, res)
+            res = []
+            for row in data:
+                values = dict(zip(key, row))
+                c_file = ConfigFile()
+                c_file.name = values['name']
+                c_file.create_time = values['create_time']
+                c_file.modify_time = values['modify_time']
+                c_file.file_type = values['file_type']
+                c_file.comment = values['comment']
+                c_file.device_type = values['device_type']
+                res.append(c_file)
+            res = sorted(res, key=lambda x: x.create_time, reverse=True)
+            return res
 
         def _update_comment(self, instance):
             data = instance.get_field_dict()
@@ -437,8 +453,8 @@
             else:
                 os.mknod(file_path + '/' + data['name'])
 
-            insert_sql = "INSERT INTO file_list(name, create_time, modify_time, type, comment, device_type) values('%s', '%s', '%s', '%s', '%s', '%s')" % (
-                data['name'] + ".cfg", create_time, create_time, file_type, data['comment'], data['device_type'])
+            insert_sql = "INSERT INTO file_list(name, create_time, modify_time, type, comment, device_type, file_type_id) values('%s', '%s', '%s', '%s', '%s', '%s', '%s')" % (
+                data['name'] + ".cfg", create_time, create_time, file_type, data['comment'], data['device_type'], CUSTOMIZE_FILE_TYPE_ID)
             db = DB.get_connected_db()
             db.execute_sql(insert_sql)
             db.close()
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/configuration/update/__init__.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/configuration/update/__init__.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/cm/models/configuration/update/__init__.py	(working copy)
@@ -85,18 +85,29 @@
             data = db.fetchall(fetchall_sql)
             db.close()
             key = ['id', 'app_name', 'build_version', 'file_size', 'md5_value', 'download_link', 'location']
-            result = [dict(zip(key, each)) for each in data]
-            for item in result:
-                file_size = item['file_size']
-                if file_size < 1024:
-                    item['file_size'] = str(file_size)
-                elif file_size < 1024 * 1024:
-                    item['file_size'] = str(file_size / 1024) + 'KB'
-                elif file_size < 1024 * 1024 * 1024:
-                    item['file_size'] = str(file_size / 1024 / 1024) + 'MB'
+
+            result = []
+            for row in data:
+                values = dict(zip(key, row))
+                update_file = Update()
+                update_file.id = values['id']
+                update_file.app_name = values['app_name']
+                update_file.build_version = values['build_version']
+                update_file.md5_value = values['file_size']
+                update_file.md5_value = values['md5_value']
+                update_file.download_link = values['download_link']
+                update_file.location = values['location']
+                file_size = values['file_size']
+                if file_size < 1024:
+                    update_file.file_size = str(file_size)
+                elif file_size < 1024 * 1024:
+                    update_file.file_size = str(file_size / 1024) + 'KB'
+                elif file_size < 1024 * 1024 * 1024:
+                    update_file.file_size = str(file_size / 1024 / 1024) + 'MB'
                 else:
-                    item['file_size'] = str(file_size / 1024 / 1024 / 1024) + 'GB'
-            return QuerySet(self._model, result)
+                    update_file.file_size = str(file_size / 1024 / 1024 / 1024) + 'GB'
+                result.append(update_file)
+            return result
 
         def _update_md5_value(self, instance):
             data = instance.get_field_dict()
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/db/llb_stats_queries.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/db/llb_stats_queries.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/db/llb_stats_queries.py	(working copy)
@@ -212,13 +212,13 @@
         if isinstance(to_time, int):
             query_string = ('select mean(linkHits) AS avgLinkHits, mean(conn) AS avgLinkConn, mean(received) AS '
                             'avgBandwidIn, mean(sent) AS avgBandwidOut, mean(linkUsage) AS avgLinkUsage '
-                            'FROM llbStats WHERE time > {} and time < {} GROUP BY linkName FILL(0);').format(from_time,
-                                                                                                             to_time)
+                            'FROM llbStats WHERE time > {} and time < {} GROUP BY linkName;').format(from_time,
+                                                                                                     to_time)
         else:
             from_time = LLBStatsDB.get_time_in_influx_format(from_time)
             query_string = ('select mean(linkHits) AS avgLinkHits, mean(conn) AS avgLinkConn, mean(received) AS '
                             'avgBandwidIn, mean(sent) AS avgBandwidOut, mean(linkUsage) AS avgLinkUsage '
-                            'FROM llbStats WHERE time > {} GROUP BY linkName FILL(0);').format(from_time)
+                            'FROM llbStats WHERE time > {} GROUP BY linkName;').format(from_time)
 
         query_string = LLBStatsDB.format_query_string(query_string)
         req_dict["body"] = 'q=' + query_string
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/manager.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/manager.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/model/manager.py	(working copy)
@@ -16,6 +16,7 @@
 from hive.model.utils import reduce_asso_value_item, get_complex_field, CONDITIONAL_NONE
 from hive.session import current_app
 from hive.utils import andebug, dump_dict, getcallargs, dict_combine
+from hive.model.query import mark_expire_all, mark_expire_one
 
 exec("import %s.company as company" % current_app())
 try:
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/report/generate_pdf_report.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/report/generate_pdf_report.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/report/generate_pdf_report.py	(working copy)
@@ -3,6 +3,7 @@
 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
 from reportlab.lib.units import inch
 from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer, Image
+import datetime
 
 from cm.lib.libbasic_operation import oper_log
 
@@ -86,7 +87,8 @@
                     elements.append(Spacer(1, 20))
                     headers = ["Time", "Inbound (bps)", "Outbound (bps)"]
                     llb_data = list(
-                        zip(llb_link_data["time"], llb_link_data["inbound_list"], llb_link_data["outbound_list"]))
+                        zip(self.convert_unix_ms_to_str(llb_link_data["time"]), llb_link_data["inbound_list"],
+                            llb_link_data["outbound_list"]))
                     table = self.get_table_data(headers, llb_data)
                     elements.append(table)
                     elements.append(Spacer(1, 30))
@@ -95,7 +97,7 @@
                     elements.append(Spacer(1, 20))
                     headers = ["Time", "Bandwidth Usage"]
                     llb_data = list(
-                        zip(llb_link_data["time"], llb_link_data["bandwidth_usage_list"]))
+                        zip(self.convert_unix_ms_to_str(llb_link_data["time"]), llb_link_data["bandwidth_usage_list"]))
                     table = self.get_table_data(headers, llb_data)
                     elements.append(table)
                     elements.append(Spacer(1, 30))
@@ -104,7 +106,7 @@
                     elements.append(Spacer(1, 20))
                     headers = ["Time", "Concurrent Connections"]
                     llb_data = list(
-                        zip(llb_link_data["time"], llb_link_data["cc_list"]))
+                        zip(self.convert_unix_ms_to_str(llb_link_data["time"]), llb_link_data["cc_list"]))
                     table = self.get_table_data(headers, llb_data)
                     elements.append(table)
                     elements.append(Spacer(1, 30))
@@ -113,7 +115,7 @@
                     elements.append(Spacer(1, 20))
                     headers = ["Time", "Hits"]
                     llb_data = list(
-                        zip(llb_link_data["time"], llb_link_data["hit_list"]))
+                        zip(self.convert_unix_ms_to_str(llb_link_data["time"]), llb_link_data["hit_list"]))
                     table = self.get_table_data(headers, llb_data)
                     elements.append(table)
                     elements.append(Spacer(1, 30))
@@ -122,3 +124,9 @@
         except Exception as e:
             oper_log('error', 'system', e.message)
             raise e  # Raise to crash and see error
+
+    def convert_unix_ms_to_str(unix_time_ms):
+        try:
+            return datetime.fromtimestamp(unix_time_ms / 1000).strftime("%Y-%m-%d %H:%M:%S")
+        except Exception:
+            return "Invalid Time"
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/report/generate_report.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/report/generate_report.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/report/generate_report.py	(working copy)
@@ -63,8 +63,8 @@
         report_name = str(category).upper() + "_" + "Statistics_Report_from_%s_to_%s.pdf" % (
             start_time, end_time)
 
-        report_generator.generate_pdf_report(report_name, category, data_dict, data_summary_dict, intervalStart,
-                                             intervalEnd)
+        report_generator.generate_pdf_report(report_name, category, data_dict, data_summary_dict, start_time,
+                                             end_time)
         if os.path.exists(REPORT_FILE_PATH + report_name):
             return HttpResponse(json.dumps({"result": True, "filename": report_name}), content_type='application/json')
         else:
Index: /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/router.py
===================================================================
--- /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/router.py	(revision 2689)
+++ /branches/amp_4_0/src/webui/webui/htdocs/new/src/hive/router.py	(working copy)
@@ -480,7 +480,7 @@
 def upload(request):
     file_content_flag = False  # return file content flag, default is False.
 
-    request_uri = request.META["REQUEST_URI"]
+    request_uri = request.path
     query = urlparse.parse_qs(urlparse.urlparse(request_uri).query)
     if query:
         if "content" in query and query["content"][0] == "true":
@@ -685,9 +685,7 @@
 
 
 def format_block(f):
-    res = str(f.read(), "utf-8")
-    rsBlocks = json.loads(res)
-    return rsBlocks
+    return json.loads(f.read())
 
 
 # example: edit block list
