import sys import six import boto.s3.connection #------------------------------------------------------------------------------ HOST_S3 = 'ss3.scayle.es' PORT_S3 = 443 ######################################################################################################### # PROGRAM ######################################################################################################### global conn # ----------------------- BASE 64 ENCODE -------------- def message_error(): # Access to OpenCayle service is wrong print ("The connection to OpenCayle service is not possible.") print ("Please, check the following issues to solve it before connect to Scayle:") print ("1) You have internet access") print ("2) Your internet access is not through a VPN") print ("3) When you generate the access key the USERID and PASSWORD were correct") print ("4) Your IP internet address is available on OpenCayle service") # ----------------------------- PARAMETERS EVALUATION ----------------------------- if len(sys.argv) >= 2: accessKey = str(sys.argv[1]) else: print ("USE: python s3CheckConnection.py '' ") sys.exit(-1) # Verification access to OpenCayle service wiht the generated accessKey try: conn = boto.connect_s3( aws_access_key_id=accessKey, aws_secret_access_key=accessKey, host=HOST_S3, port=PORT_S3, is_secure=True, calling_format=boto.s3.connection.OrdinaryCallingFormat(), ) except: message_error() sys.exit(-2) try: for bucket in conn.get_all_buckets(): exit except: message_error() sys.exit(-3) print ("Your accessKey connects successfully to OpenCayle") sys.exit(0)