#!/usr/bin/env python
import os
import tempfile

filename = None

def set_start_processing():
    global filename
    fd, filename = tempfile.mkstemp()
    os.write(fd, 'processing')
    os.close(fd)

def check_processing():
    try:
        f = open(filename ,'r')
        t = f.readline()
        f.close
    except TypeError:
        return ''
    except IOError:
        return ''
    return t

def set_fin_processing():
    global filename
    f = open(filename,'w')
    f.write('done')
    f.close()

def del_temp_file():
    global filename
    try:
        filename = None
        os.remove(filename)
    except OSError:
        pass
    except TypeError:
        pass
