Connect to a JIRA server.

            Arguments:
                |  JIRAUsername (string)  	|  (Optional) A JIRA Username you wish to authenticate with, will authorise with anonymous account if left empty      				|
                |  JIRAPassword (string)  	|  (Optional) If a username was specified and a password is not the user will be prompted for password at runtime 					|
                |  options (dictionary) 	|  (Optional) A dictionary of options that the JIRA connection will be initialied with 	                                            |

            This must be called first to be able to do most JIRA actions such as creating a new issue and assigning users.
            When connecting to JIRA you may need to authenticate a user. This can be done by passing in Username and Password as parameters. However, should you wish to not have a sensitive password saved in a file,  an option is available to not pass in a Password and a prompt will appear asking for the JIRA password at runtime.


            'connect to jira' can be called on its own and will default options to:
                '{'rest_api_version': '2', 'verify': True,
                'server': 'http://localhost:2990/jira', 'headers': {'X-Atlassian-Token': 'nocheck'},
                'rest_path': 'api', 'resilient': False, 'async': False}'
            These can all be customised as needed.

            Examples:
                |  *Keyword*        |  *Parameters* | 									| 									|
                |  connect to jira  |  				|           						|                          			|
                |  connect to jira  |  asimmons	    | options= {'http://devjira01'} 	|    								|
                |  connect to jira  |  asimmond 	| MyP@ssword 						| {'server': http://devjira01'} 	|

def connect_to_jira(self, JIRAUsername=None,
                        JIRAPassword=None, options=None):
        """
        Connect to a JIRA server.

            Arguments:
                |  JIRAUsername (string)  	|  (Optional) A JIRA Username you wish to authenticate with, will authorise with anonymous account if left empty      				|
                |  JIRAPassword (string)  	|  (Optional) If a username was specified and a password is not the user will be prompted for password at runtime 					|
                |  options (dictionary) 	|  (Optional) A dictionary of options that the JIRA connection will be initialied with 	                                            |

            This must be called first to be able to do most JIRA actions such as creating a new issue and assigning users.
            When connecting to JIRA you may need to authenticate a user. This can be done by passing in Username and Password as parameters. However, should you wish to not have a sensitive password saved in a file,  an option is available to not pass in a Password and a prompt will appear asking for the JIRA password at runtime.


            'connect to jira' can be called on its own and will default options to:
                '{'rest_api_version': '2', 'verify': True,
                'server': 'http://localhost:2990/jira', 'headers': {'X-Atlassian-Token': 'nocheck'},
                'rest_path': 'api', 'resilient': False, 'async': False}'
            These can all be customised as needed.

            Examples:
                |  *Keyword*        |  *Parameters* | 									| 									|
                |  connect to jira  |  				|           						|                          			|
                |  connect to jira  |  asimmons	    | options= {'http://devjira01'} 	|    								|
                |  connect to jira  |  asimmond 	| MyP@ssword 						| {'server': http://devjira01'} 	|
        """

        if JIRAUsername is not None and (JIRAPassword is "" or JIRAPassword is None):
            JIRAPassword = getpass.getpass("\nJIRA Password: ")
		
        print JIRAUsername

        JIRAOptions = eval(options)
        if JIRAUsername is None:
            try:
                self.jira = JIRA(JIRAOptions)
            except:
                sys.__stdout__.write("\nAuthentication to JIRA unsuccessful. Ensure the user used has sufficient access and that Username and Password were correct\n\n")
                sys.exit(1)

        else:
            try:
                self.jira = JIRA(options=JIRAOptions, basic_auth=(str(JIRAUsername),
                                 str(JIRAPassword)))
            except:
                sys.__stdout__.write("\nAuthentication to JIRA unsuccessful. Ensure the user used has sufficient access and that Username and Password were correct\n\n")
                sys.exit(1)