Permalink
Browse files

-

  • Loading branch information...
1 parent 54eca11 commit 665b89abed0a3bbb5295ac01c63cf2be50041dc9 @frutik committed Oct 17, 2011
Showing with 36 additions and 35 deletions.
  1. +36 −35 yaware.py
View
@@ -52,39 +52,7 @@ def GetActiveWindow():
return time.time(), result['id'], md5.md5(str(result)).hexdigest(), result
-try:
- config = ConfigParser.ConfigParser()
- config.read(CONFIG_FILE)
- dsn = config.get('SQL', 'dsn')
- sleep_time = float(config.get('GENERAL', 'sleep'))
-except:
- print 'config not found'
- sys.exit()
-
-class YawareEvent(SQLObject):
- added = StringCol()
- windowid = StringCol()
- windowhash = StringCol()
- WM_CLIENT_LEADER = StringCol()
- WM_NAME = StringCol()
- WM_CLASS = StringCol()
- WM_CLIENT_MACHINE = StringCol()
-
-
-connection = connectionForURI(dsn)
-sqlhub.processConnection = connection
-
-try:
- YawareEvent.createTable()
-except:
- pass
-
-while True:
- time.sleep(sleep_time)
- row = GetActiveWindow()
-
- logging.debug(row)
-
+def process_window(row):
try:
added = row[0]
except:
@@ -119,8 +87,7 @@ class YawareEvent(SQLObject):
WM_CLIENT_MACHINE = row[3]['WM_CLIENT_MACHINE']
except:
WM_CLIENT_MACHINE = ''
-
-
+
YawareEvent(
added = added,
windowid = windowid,
@@ -130,5 +97,39 @@ class YawareEvent(SQLObject):
WM_CLASS = WM_CLASS,
WM_CLIENT_MACHINE = WM_CLIENT_MACHINE
)
+
+try:
+ config = ConfigParser.ConfigParser()
+ config.read(CONFIG_FILE)
+ dsn = config.get('SQL', 'dsn')
+ sleep_time = float(config.get('GENERAL', 'sleep'))
+except:
+ print 'config not found'
+ sys.exit()
+
+class YawareEvent(SQLObject):
+ added = StringCol()
+ windowid = StringCol()
+ windowhash = StringCol()
+ WM_CLIENT_LEADER = StringCol()
+ WM_NAME = StringCol()
+ WM_CLASS = StringCol()
+ WM_CLIENT_MACHINE = StringCol()
+
+
+connection = connectionForURI(dsn)
+sqlhub.processConnection = connection
+
+try:
+ YawareEvent.createTable()
+except:
+ pass
+
+while True:
+ time.sleep(sleep_time)
+ row = GetActiveWindow()
+ logging.debug(row)
+
+ process_window(row)

0 comments on commit 665b89a

Please sign in to comment.