<commit_before># worker2.py


import datetime
import pyrax
import medareda_worker_lib
import os

class Worker2(object):
    
    def __init__(self,in_table):
        self.conn = medareda_worker_lib.get_conn()
        self.in_table = in_table
        
        self.server_id = self._getServerId()
        self.setStatusIdle()
        
    def _getServerId(self):
        hostname = os.uname()[1]
        server_id = hostname.split('-')[1]
        print server_id
        #return 4
        return int(server_id)


    def setStatusIdle(self):
        self._setStatus('idle')  
    
    def setStatusWorking(self):
        self._setStatus('working')
        
    def _setStatus(self, status):
        cur = self.conn.cursor()
        now = datetime.datetime.now()
    
        sql = "UPDATE Worker SET status = '%s', since = '%s' WHERE serverId = %s" %(status,now,self.server_id)
        cur.execute(sql)
        #print sql
        cur.execute(sql)
        self.conn.commit()
        self.conn.close()
        
    def doWork(self):
        print 'process in data'
        # ( if status == deleting, return )
        # get amount of work to to
        # while work todo
        #   set worker status to work
        #   get work
        #   process work
        # set status to idle


def testWorker2():
    in_table = 'iPrice'
    w = Worker2(in_table)
    print w.server_id
    w.doWork()
    
testWorker2()<commit_msg>correct worker2<commit_after># worker2.py


import datetime
import pyrax
import medareda_lib
import os

class Worker2(object):
    
    def __init__(self,in_table):
        self.conn = medareda_lib.get_conn()
        self.in_table = in_table
        
        self.server_id = self._getServerId()
        self.setStatusIdle()
        
    def _getServerId(self):
        hostname = os.uname()[1]
        server_id = hostname.split('-')[1]
        print server_id
        #return 4
        return int(server_id)


    def setStatusIdle(self):
        self._setStatus('idle')  
    
    def setStatusWorking(self):
        self._setStatus('working')
        
    def _setStatus(self, status):
        cur = self.conn.cursor()
        now = datetime.datetime.now()
    
        sql = "UPDATE Worker SET status = '%s', since = '%s' WHERE serverId = %s" %(status,now,self.server_id)
        cur.execute(sql)
        #print sql
        cur.execute(sql)
        self.conn.commit()
        self.conn.close()
        
    def doWork(self):
        print 'process in data'
        # ( if status == deleting, return )
        # get amount of work to to
        # while work todo
        #   set status to work
        #   get work
        #   process work
        # set status to idle


def testWorker2():
    in_table = 'iPrice'
    w = Worker2(in_table)
    print w.server_id
    w.doWork()
    
testWorker2()

{'fraction_non_alphanumeric': 0.10290986515259049, 'fraction_numerical': 0.00603264726756565, 'mean_word_length': 1.9303534303534304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3789987', 'n_tokens_mistral': 902, 'n_tokens_neox': 887, 'n_words': 211}