Monthly Archives: April 2016

SimpleHTTPServer with auth

import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64

key = ""

class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
print "send header"
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()

def do_AUTHHEAD(self):
print "send header"
self.send_response(401)
self.send_header('WWW-Authenticate', 'Basic realm=\"Test\"')
self.send_header('Content-type', 'text/html')
self.end_headers()

def do_GET(self):
global key
''' Present frontpage with user authentication. '''
if self.headers.getheader('Authorization') == None:
self.do_AUTHHEAD()
self.wfile.write('no auth header received')
pass
elif self.headers.getheader('Authorization') == 'Basic '+key:
SimpleHTTPRequestHandler.do_GET(self)
pass
else:
self.do_AUTHHEAD()
self.wfile.write(self.headers.getheader('Authorization'))
self.wfile.write('not authenticated')
pass

def test(HandlerClass = AuthHandler,
ServerClass = BaseHTTPServer.HTTPServer):
BaseHTTPServer.test(HandlerClass, ServerClass)

if __name__ == '__main__':
if len(sys.argv)<3: print "usage SimpleAuthServer.py [port] [username:password]" sys.exit() key = base64.b64encode(sys.argv[2]) test()

install remi

On CentOS/RHEL/Scientific Linux 7 x86_64:
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm

On CentOS/RHEL/Scientific Linux 6 i386 or x86_64:
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm

## for RHEL only
rhn-channel –add –channel=rhel-$(uname -i)-server-optional-6
On CentOS/RHEL/Scientific Linux 5 i386 or x86_64:

wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh remi-release-5.rpminstall

remi install php55

Replacement of default PHP by version 5.6 installation (simplest):
yum-config-manager --enable remi-php56
yum update

Parallel installation of version 5.6 as Software Collection (x86_64 only):
yum --enablerepo=remi install php56

Replacement of default PHP by version 5.5 installation (simplest):
yum-config-manager --enable remi-php55
yum update

Parallel installation of version 5.5 as Software Collection (x86_64 only):
yum --enablerepo=remi install php55

integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

delete FROM `catalog_product_entity_datetime` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_decimal` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_gallery` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_group_price` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_int` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_media_gallery` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_text` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_tier_price` where entity_id not in (select entity_id from catalog_product_entity);
delete FROM `catalog_product_entity_varchar` where entity_id not in (select entity_id from catalog_product_entity);
#originals with formatting fixed:
delete from `catalog_category_product` WHERE product_id not in(select entity_id from catalog_product_entity);
delete from `catalog_category_product` WHERE category_id not in(select entity_id from catalog_category_entity);
delete from `catalog_product_website` WHERE product_id not in(select entity_id from catalog_product_entity);
delete from `catalog_product_index_eav_idx` WHERE entity_id not in(select entity_id from catalog_product_entity);
delete from `catalog_product_index_eav` WHERE entity_id not in(select entity_id from catalog_product_entity);
delete from `catalog_product_link` WHERE product_id not in(select entity_id from catalog_product_entity);
delete from `catalog_product_relation` WHERE parent_id not in(select entity_id from catalog_product_entity);