11#Copyright (C) 2011,2012 Colin Rice
22#This software is licensed under an included MIT license.
33#See the file entitled LICENSE
4- #If you were not provided with a copy of the license please contact:
4+ #If you were not provided with a copy of the license please contact:
55# Colin Rice colin@daedrum.net
66
77"""
@@ -17,36 +17,36 @@ def __patch():
1717 global pools
1818 if pools == None :
1919 pools = load_from_db ()
20-
20+
2121def load_from_db ():
2222 """
2323 Load pools from database
2424 """
2525 columns = [ 'Server TEXT' ,
2626 'Percentage INTEGER' ,
2727 'Priority INTEGER' ]
28-
28+
2929 bitHopper .Database .Commands .Create_Table ('Pools' , columns )
3030 results = bitHopper .Database .execute ('SELECT Server, Percentage, Priority FROM Pools' )
31-
31+
3232 pools = {}
33-
33+
3434 for server , percentage , priority in results :
3535 if server not in pools :
3636 pools [server ] = {'percentage' :percentage , 'priority' :priority }
3737 else :
3838 #Really should delete the duplicate entry
3939 pass
40-
40+
4141 return pools
42-
42+
4343def len_pools ():
4444 """
4545 Return the number of pools with special things
4646 """
4747 __patch ()
4848 return len (pools )
49-
49+
5050def set_priority (server , prio ):
5151 """
5252 Sets pool priority, higher is better
@@ -57,7 +57,7 @@ def set_priority(server, prio):
5757 pools [server ] = {'priority' :0 , 'percentage' :0 }
5858 pools [server ]['priority' ] = int (prio )
5959 bitHopper .Database .execute ("INSERT INTO Pools VALUES ('%s',%s,%s)" % (server , int (prio ), 0 ))
60-
60+
6161def get_priority (server ):
6262 """
6363 Gets pool priority
@@ -66,7 +66,7 @@ def get_priority(server):
6666 if server not in pools :
6767 return 0
6868 return pools [server ]['priority' ]
69-
69+
7070def set_percentage (server , perc ):
7171 """
7272 Sets pool percentage, the amount of work we should always feed to the server
@@ -77,7 +77,7 @@ def set_percentage(server, perc):
7777 pools [server ] = {'priority' :0 , 'percentage' :0 }
7878 pools [server ]['percentage' ] = int (perc )
7979 bitHopper .Database .execute ("INSERT INTO Pools VALUES ('%s',%s,%s)" % (server , 0 , int (perc )))
80-
80+
8181def get_percentage (server ):
8282 """
8383 Gets pool percentage
@@ -86,7 +86,7 @@ def get_percentage(server):
8686 if server not in pools :
8787 return 0
8888 return pools [server ]['percentage' ]
89-
89+
9090def percentage_server ():
9191 """
9292 Gets all server with a percentage
@@ -96,7 +96,3 @@ def percentage_server():
9696 if info ['percentage' ] > 0 :
9797 yield server , info ['percentage' ]
9898
99-
100-
101-
102-
0 commit comments