summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorRawng <rawng.github@gmail.com>2015-06-01 19:56:10 -0400
committerRawng <rawng.github@gmail.com>2015-06-01 19:56:10 -0400
commit1e8140f0f62ecfd0ccbe046cf6ea9faed926f327 (patch)
treeca92a7a0cd2256ffbb0b43563ee183400d1aacc5 /utils.py
parentb4f19a8e28cf09b7c8a042c8faf068217669bca5 (diff)
parentb7e3823588ae9354daf5fc0a0cbf27b699afb7d5 (diff)
downloadmanamarket-1e8140f0f62ecfd0ccbe046cf6ea9faed926f327.tar.gz
manamarket-1e8140f0f62ecfd0ccbe046cf6ea9faed926f327.tar.bz2
manamarket-1e8140f0f62ecfd0ccbe046cf6ea9faed926f327.tar.xz
manamarket-1e8140f0f62ecfd0ccbe046cf6ea9faed926f327.zip
Merge branch 'storage'
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/utils.py b/utils.py
index 52d51b6..6273bef 100644
--- a/utils.py
+++ b/utils.py
@@ -13,6 +13,7 @@ import time
import mutex
import threading
from net.packet_out import *
+from threading import _Timer
allowed_chars = "abcdefghijklmnoprstquvwxyzABCDEFGHIJKLMNOPRSTQUVWXYZ1234567890-_+=!@$%^&*();'<>,.?/~`| "
@@ -86,6 +87,15 @@ class ItemLog:
file_node.write(str(item_id)+" "+str(amount)+" "+str(price)+" "+str(time.time())+" "+name+"\n")
file_node.close()
+class DelistedLog:
+ def __init__(self):
+ self.log_file = 'data/logs/delisted.log'
+
+ def add_item(self, item_id, amount, name):
+ file_node = open(self.log_file, 'a')
+ file_node.write(str(item_id)+" "+str(amount)+" "+str(time.time())+" "+name+"\n")
+ file_node.close()
+
class TraderState:
""" Stores information regarding a trade request"""
def __init__(self):
@@ -129,5 +139,18 @@ class Broadcast:
self.Active = False
self.shop_broadcast.join()
+class CustomTimer(_Timer):
+ def __init__(self, interval, function, args=[], kwargs={}):
+ self._original_function = function
+ super(CustomTimer, self).__init__(interval, self._do_execute, args, kwargs)
+ self._result = None
+
+ def _do_execute(self, *a, **kw):
+ self._result = self._original_function(*a, **kw)
+
+ def join(self):
+ super(CustomTimer, self).join()
+ return self._result
+
if __name__ == '__main__':
print "Do not run this file directly. Run main.py"