Ejemplo n.º 1
0
def convert():
    while True:
        try:
            sqs = httpsqs('127.0.0.1', '1218', 'pdf2swf')
            result = sqs.gets('pdf2swf')
            if result:
                data = result['data']
                if data != False and data != 'HTTPSQS_ERROR':
                    op = json.loads(data)
                    input_file = service_root + '../../data/' + op['folder'] + op['name']
                    output_file_folder = service_root + '../../public/attachments/' + op['folder']
                    output_file = output_file_folder + op['raw_name'] + '.swf'
                    try:
                        if not os.path.exists(output_file_folder):
                            os.makedirs(output_file_folder)
                        status = subprocess.call(converter % (input_file, output_file), shell = True)
                        sql = "UPDATE docs SET path = '%s', status = '%s' WHERE id=%d"
                        if status == 0:
                            sql = sql % (op['folder'] + op['raw_name'] + '.swf', 'success', op['id'])
                        else:
                            sql = sql % ('', 'fail', op['id'])
                        db = MySQLdb.connect(host='localhost',user='******',passwd='VMeHUf5zS5XnKWh4',db='wenku-demo', read_default_file="/data/lampstack/mysql/my.cnf")
                        cursor = db.cursor()
                        cursor.execute(sql)
                        cursor.close()
                        db.close()
                    except Exception, e:
                        print e
        except Exception, e:
            print e
  	time.sleep(1)
Ejemplo n.º 2
0
def convert():
    while True:
        try:
            sqs = httpsqs('127.0.0.1', '1218', 'office2pdf')
            result = sqs.gets('office2pdf')
            if result:
                data = result['data']
                if data != False and data != 'HTTPSQS_ERROR':
                    op = json.loads(data)
                    input_file = service_root + '../../data/' + op['folder'] + op['name']
                    output_file = service_root + '../../data/' + op['folder']+ op['raw_name']+'.pdf'
                    status = subprocess.call(converter % (input_file, output_file), shell = True)
                    flag = False
                    if status == 0:
                        op['name'] = op['raw_name'] + '.pdf'
                        flag = sqs.put(json.dumps(op), 'pdf2swf')
                    if not flag:
                        sql = "UPDATE docs SET path = '%s', status = '%s' WHERE id=%d"
                        sql = sql % ('', 'fail', op['id'])
                        db = MySQLdb.connect(host='localhost',user='******',passwd='SDVVArzGBLu5bWX8',db='wenku-demo', read_default_file="/data/lampstack/mysql/my.cnf")
                        cursor = db.cursor()
                        cursor.execute(sql)
                        cursor.close()
                        db.commit()
                        db.close()
        except Exception, e:
            print e
  	
        time.sleep(1)
Ejemplo n.º 3
0
def convert():
    while True:
        try:
            sqs = httpsqs("127.0.0.1", "1218", "office2pdf")
            result = sqs.gets("office2pdf")
            if result:
                data = result["data"]
                if data != False and data != "HTTPSQS_ERROR":
                    op = json.loads(data)
                    input_file = service_root + "../../data/" + op["folder"] + op["name"]
                    output_file = service_root + "../../data/" + op["folder"] + op["raw_name"] + ".pdf"
                    status = subprocess.call(converter % (input_file, output_file), shell=True)
                    flag = False
                    if status == 0:
                        op["name"] = op["raw_name"] + ".pdf"
                        flag = sqs.put(json.dumps(op), "pdf2swf")
                    if not flag:
                        sql = "UPDATE docs SET path = '%s', status = '%s' WHERE id=%d"
                        sql = sql % ("", "fail", op["id"])
                        db = MySQLdb.connect(
                            host="localhost",
                            user="******",
                            passwd="SDVVArzGBLu5bWX8",
                            db="wenku-demo",
                            read_default_file="/data/lampstack/mysql/my.cnf",
                        )
                        cursor = db.cursor()
                        cursor.execute(sql)
                        cursor.close()
                        db.close()
        except Exception, e:
            print e

        time.sleep(1)
Ejemplo n.º 4
0
def convert():
    while True:
        try:
            sqs = httpsqs('127.0.0.1', '1218', 'office2pdf')
            result = sqs.gets('office2pdf')
            if result:
                data = result['data']
                if data != False and data != 'HTTPSQS_ERROR':
                    op = json.loads(data)
                    input_file = service_root + '../../data/' + op[
                        'folder'] + op['name']
                    output_file = service_root + '../../data/' + op[
                        'folder'] + op['raw_name'] + '.pdf'
                    status = subprocess.call(converter %
                                             (input_file, output_file),
                                             shell=True)
                    flag = False
                    if status == 0:
                        op['name'] = op['raw_name'] + '.pdf'
                        flag = sqs.put(json.dumps(op), 'pdf2swf')
                    if not flag:
                        sql = "UPDATE docs SET path = '%s', status = '%s' WHERE id=%d"
                        sql = sql % ('', 'fail', op['id'])
                        db = MySQLdb.connect(
                            host='localhost',
                            user='******',
                            passwd='SDVVArzGBLu5bWX8',
                            db='wenku-demo',
                            read_default_file="/data/lampstack/mysql/my.cnf")
                        cursor = db.cursor()
                        cursor.execute(sql)
                        cursor.close()
                        db.close()
        except Exception, e:
            print e

        time.sleep(1)
Ejemplo n.º 5
0
# -*- coding:utf-8 -*-
from httpsqs_client import httpsqs

sqs = httpsqs('10.249.200.168', '1218', 'test')

def test_put():
    l = ['a','b', 'c', 1, 2, 3]
    for node in l:
        print sqs.put(node)
        print sqs.put(node, 'other')

def test_get():
    print sqs.get()
    print sqs.get('other')
def test_gets():
    print sqs.gets()
    print sqs.gets('other')


def test_status():
    print sqs.status()
    print sqs.status('other')

def test_view(pos):
    print sqs.view(pos)
    print sqs.view(pos,'other')

def test_status_json():
    print sqs.status_json()
    print sqs.status_json('other')