Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 901472 Details for
Bug 1103787
[RFE] rhc snapshot and restore ops should not return until all cartridges are available again
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
wsg.py file for inserting test data into database
wsgi.py (text/x-python), 4.22 KB, created by
Oleg Fayans
on 2014-06-02 14:37:49 UTC
(
hide
)
Description:
wsg.py file for inserting test data into database
Filename:
MIME Type:
Creator:
Oleg Fayans
Created:
2014-06-02 14:37:49 UTC
Size:
4.22 KB
patch
obsolete
>#!/usr/bin/python >import os >#import commands >from cgi import escape >import sys >if sys.version[0] == "2": > from urlparse import parse_qs > from MySQLdb import connect >else: > from urllib.parse import parse_qs > from pymysql import Connect as connect > >virtenv = os.environ['APPDIR'] + '/virtenv/' >os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages') >virtualenv = os.path.join(virtenv, 'bin/activate_this.py') >try: > if sys.version_info.major == 2: > execfile(virtualenv, dict(__file__=virtualenv)) > else: > exec(open(virtualenv).read()) >except IOError: > pass ># ># IMPORTANT: Put any additional includes below this line. If placed above this ># line, it's possible required libraries won't be in your searchable path ># > >def application(environ, start_response): > parameters = parse_qs(environ.get('QUERY_STRING', '')) > ctype = 'text/plain' > con=connect(host=os.environ['OPENSHIFT_MYSQL_DB_HOST'], user=os.environ['OPENSHIFT_MYSQL_DB_USERNAME'], passwd=os.environ['OPENSHIFT_MYSQL_DB_PASSWORD'], db=os.environ['OPENSHIFT_APP_NAME'], port=int(os.environ['OPENSHIFT_MYSQL_DB_PORT'])) > cursor = con.cursor() > cursor.execute('CREATE TABLE IF NOT EXISTS info(id INT NOT NULL AUTO_INCREMENT, data CHAR(200), PRIMARY KEY (id));') > con.commit() > if environ['PATH_INFO'] == '/health': > response_body = "1" > elif environ['PATH_INFO'] == '/env': > response_body = ['%s: %s' % (key, value) > for key, value in sorted(environ.items())] > response_body = '\n'.join(response_body) > elif environ['PATH_INFO'] == '/insert': > if 'size' in parameters: > size = int(escape(parameters['size'][0])) > else: > size = 500000 > cursor.execute('SET autocommit=0;') > for i in range(size): > cursor.execute('INSERT INTO info VALUES(NULL, "This is testing data for testing snapshoting and restoring big data in mysql database.This is testing data for testing snapshoting and restoring big data in mysql database.");') > cursor.execute('COMMIT;') > cursor.execute('SET autocommit=1;') > response_body = '''Gear DNS: %s >SQL statements: >INSERT INTO info VALUES(NULL, 'This is testing data for testing snapshoting and restoring big data in mysql database.This is testing data for testing snapshoting and restoring big data in mysql database.'); >%s records have been inserted into mysql''' % (os.environ['OPENSHIFT_GEAR_DNS'], size) > elif environ['PATH_INFO'] == '/delete': > cursor.execute('DELETE FROM info;'); > response_body = 'Gear DNS: %s\nAll the records have been deleted from mysql database' % (os.environ['OPENSHIFT_GEAR_DNS']) > elif environ['PATH_INFO'] == '/show': > cursor.execute('SELECT COUNT(*) FROM info;') > try: > count = int(cursor.fetchone()[0]) > cursor.execute('SELECT * FROM info LIMIT 0, 1;') > row = cursor.fetchone() > except: > count = 0 > response_body = 'Gear DNS: %s\n' % (os.environ['OPENSHIFT_GEAR_DNS']) > if count == 0: > response_body += 'There is no record in database' > else: > response_body += 'There are %d records in database.\nHere is one row:\n%s\n' % (count, row) > else: > ctype = 'text/plain' > response_body = '''[rhc-cartridge]snapshot/restore big mysql data to existing app\n[rhc-cartridge]snapshot/restore big mysql data to new app\n''' > > cursor.execute('COMMIT;') > cursor.close() > con.commit() > con.close() > status = '200 OK' > response_headers = [('Content-Type', ctype), ('Content-Length', str(len(response_body)))] > # > start_response(status, response_headers) > return [response_body] > ># ># Below for testing only ># >if __name__ == '__main__': > from wsgiref.simple_server import make_server > httpd = make_server('localhost', 8051, application) > # Wait for a single request, serve it and quit. > httpd.handle_request()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1103787
: 901472