def processSalesForce(args): _username, _password, soql = args try: sfdc = Connection.connect(_username, _password) ret = sfdc.query(soql) except ApiFault, details: print 'ERROR due to "%s".' % (details) traceback.print_exc() ret = []
def __init__(self, username='', password='', debug=False): self.username = username self.password = password self.debug = debug self.result = {} self.logger = netsvc.Logger() try: self.sfdc = Connection.connect(self.username,self.password) except: self.sfdc = False
def connect_check(self): try: timestamp = self.sfdc.getServerTimestamp() self.logger.notifyChannel('SalesForce', netsvc.LOG_INFO, 'Connected to server successfully. Server Timestamp : %s' % (timestamp,)) return True except: try: self.sfdc = Connection.connect(self.username,self.password) except: self.logger.notifyChannel('SalesForce', netsvc.LOG_WARNING, 'Could not connect to the server') return False return True
def __init__(self, username, password): self.__username__ = username self.__password__ = password self.__sfdc__ = None from pyax.connection import Connection from pyax.exceptions import ApiFault try: self.__sfdc__ = Connection.connect(self.username, self.password) return True except AttributeError, details: from vyperlogix.misc import _utils info_string = _utils.formattedException(details=details) print >> sys.stderr, info_string
def perform_login(self,end_point='https://test.salesforce.com/services/Soap/u/14.0',isVerbose=False): self.sfContext.login_endpoint = end_point try: self.__lastError__ = '' if (isVerbose): print '(%s) :: self.username is "%s".' % (ObjectTypeName.objectSignature(self),self.username) if (self.is_running_securely_for_developers): print 'self.password is "%s".' % (self.password) if (isVerbose): print '(%s) :: self.sfContext.login_endpoint is "%s".' % (ObjectTypeName.objectSignature(self),self.sfContext.login_endpoint) self.__sfdc__ = Connection.connect(self.username, self.password, context=self.sfContext) if (isVerbose): print '(%s) :: self.__sfdc__ is "%s".' % (ObjectTypeName.objectSignature(self),self.__sfdc__) except Exception as details: info_string = _utils.formattedException(details=details) self.__lastError__ = info_string try: del self.__sfdc__ finally: self.__sfdc__ = None
def processSalesForce(args, context1, context2, isStaging=False): import sys,time from pyax.connection import Connection from pyax.exceptions import ApiFault if (len(args) == 3): _username, _password, soql = args elif (len(args) in [4,5]): if (len(args) == 4): _username, _password, soql, isStaging = args elif (len(args) == 5): _username, _password, _token, soql, isStaging = args isStaging = booleanize(isStaging) print '\n' print '='*80 print '_username=[%s]' % _username print '_password=[%s]' % _password print '_token=[%s]' % _token print 'soql=[%s]' % soql print 'isStaging=[%s]' % isStaging print 'context1=[%s]' % context1 print 'context2=[%s]' % context2 try: _beginTime = time.time() _ctx = getSalesForceContext() if (isStaging): _srvs = _ctx.get__login_servers() if (_srvs.has_key('production')) and (_srvs.has_key('sandbox')): _ctx.login_endpoint = _ctx.login_endpoint.replace(_srvs['production'],_srvs['sandbox']) _end = _ctx.login_endpoint sfdc = Connection.connect(_username, _password, token=_token, context=_ctx) print 'sfdc.endpoint=[%s]' % sfdc.endpoint if (isinstance(soql,dict)): className = '' if (soql.has_key(const_tableName_symbol)): className = soql[const_tableName_symbol] isProcessingCreation = False if (soql.has_key(const_isProcessingCreation_symbol)): isProcessingCreation = soql[const_isProcessingCreation_symbol] isProcessingDeletion = False if (soql.has_key(const_isProcessingDeletion_symbol)): isProcessingDeletion = soql[const_isProcessingDeletion_symbol] isProcessingUpdate = False if (soql.has_key(const_isProcessingUpdate_symbol)): isProcessingUpdate = soql[const_isProcessingUpdate_symbol] contents = [] if (soql.has_key(const_contents_symbol)): contents = listify(soql[const_contents_symbol]) if (isProcessingCreation): val = createSalesForceObject(sfdc,className,contents) if (isProcessingDeletion): val = deleteSalesForceObject(sfdc,contents) if (isProcessingUpdate): val = updateSalesForceObject(sfdc,className,contents) else: val = sfdc.query(soql) _endTime = time.time() ret = asXML(val,_endTime-_beginTime) except ApiFault, details: print 'ERROR due to "%s".' % (details) traceback.print_exc() ret = '<error>%s</error>' % details
try: default_type = config.get('salesforce','default-type') except Exception, ex: pass try: default_status = config.get('salesforce','default-status') except Exception, ex: pass try: default_priority = config.get('salesforce','default-priority') except Exception, ex: pass return Connection.connect(UNAME,PWORD) def add_prime_command(command): if prime_command != "": raise TooManyPrimeCommands(prime_command, command) return command def build_command_dict(opts, case_number=None): command_dict = {} prime_command=""