Beispiel #1
0
def loginToSalesforce(username, password, sectoken):
    """
  Initializes global Salesforce connection handle, "sf"
  """
    global sf
    sf = SforceEnterpriseClient(wsdlFile)
    # API login seems to always need security token
    result = sf.login(username, password, sectoken)
    print('Connected to "%s"' % result.serverUrl)
    print('  as user "%s" Org Company Name: "%s" Org Id: "%s"' % \
      (result.userInfo.userFullName,
       result.userInfo.organizationName,
       result.userInfo.organizationId))
    print("  org type is %s sandbox" % (tern(result.sandbox, "", "NOT")))
    global invokingUser
    invokingUser = result.userInfo.userFullName
Beispiel #2
0
def loginToSalesforce(username, password, sectoken):
  """
  Initializes global Salesforce connection handle, "sf"
  """
  global sf
  sf = SforceEnterpriseClient(wsdlFile)
  # API login seems to always need security token
  result = sf.login(username, password, sectoken)
  print 'Connected to "%s"' % result.serverUrl
  print '  as user "%s" Org Company Name: "%s" Org Id: "%s"' % \
    (result.userInfo.userFullName, 
     result.userInfo.organizationName, 
     result.userInfo.organizationId)
  print "  org type is %s sandbox" % (tern(result.sandbox,"","NOT"))
  global invokingUser
  invokingUser = result.userInfo.userFullName
Beispiel #3
0
    def connection2(self):
        '''Behavior: Log in to Salesforce
           Return: Handle to connection

           Uses Salesforce Python Toolkit

           connection2 used for queryAll functionality not supported
           by Python Simple-Salesforce
        '''
        if '_connection2' not in self.__dict__:
            user      = self.conf['salesforce']['user']
            password  = self.conf['salesforce']['password']
            token     = self.conf['salesforce']['token']
            wsdl_file = self.conf['salesforce']['wsdl_file']
            h = SforceEnterpriseClient(wsdl_file)
            h.login(user, password, token)

            self._connection2 = h
        return self._connection2
 def setUp(self):
     if self.h is None:
         self.h = SforceEnterpriseClient('../enterprise.wsdl.xml')
         self.h.login(test_config.USERNAME, test_config.PASSWORD,
                      test_config.TOKEN)
class SforceEnterpriseClientTest(test_base.SforceBaseClientTest):
    wsdlFormat = 'Enterprise'
    h = None

    def setUp(self):
        if self.h is None:
            self.h = SforceEnterpriseClient('../enterprise.wsdl.xml')
            self.h.login(test_config.USERNAME, test_config.PASSWORD,
                         test_config.TOKEN)

    def testSearchOneResult(self):
        result = self.h.search(
            'FIND {Single User} IN Name Fields RETURNING Lead(Name, Phone, Fax, Description, DoNotCall)'
        )

        self.assertEqual(len(result.searchRecords), 1)
        self.assertEqual(result.searchRecords[0].record.Name, 'Single User')
        self.assertTrue(
            isinstance(result.searchRecords[0].record.DoNotCall, bool))
        # make sure we get None and not ''
        self.assertFalse(hasattr(result.searchRecords[0].record,
                                 'Description'))

    def testSearchManyResults(self):
        result = self.h.search(
            u'FIND {Joë Möke} IN Name Fields RETURNING Lead(Name, Phone, Company, DoNotCall)'
        )

        self.assertTrue(len(result.searchRecords) > 1)
        for searchRecord in result.searchRecords:
            self.assertEqual(searchRecord.record.Name, u'Joë Möke')
            self.assertEqual(searchRecord.record.Company, u'你好公司')
            self.assertTrue(
                isinstance(result.searchRecords[0].record.DoNotCall, bool))

    def testUpdateOneFieldToNull(self):
        self.setHeaders('update')

        (result, lead) = self.createLead(True)

        lead.fieldsToNull = ('Email')
        lead.Email = None

        result = self.h.update(lead)
        self.assertTrue(result.success)
        self.assertEqual(result.id, lead.Id)

        result = self.h.retrieve('FirstName, LastName, Company, Email', 'Lead',
                                 (lead.Id))
        self.assertEqual(result.FirstName, u'Joë')
        self.assertEqual(result.LastName, u'Möke')
        self.assertEqual(result.Company, u'你好公司')
        self.assertFalse(hasattr(result, 'Email'))

    def testUpdateTwoFieldsToNull(self):
        self.setHeaders('update')

        (result, lead) = self.createLead(True)

        lead.fieldsToNull = ('FirstName', 'Email')
        lead.Email = None
        lead.FirstName = None

        result = self.h.update(lead)
        self.assertTrue(result.success)
        self.assertEqual(result.id, lead.Id)

        result = self.h.retrieve('FirstName, LastName, Company, Email', 'Lead',
                                 (lead.Id))

        self.assertFalse(hasattr(result, 'FirstName'))
        self.assertEqual(result.LastName, u'Möke')
        self.assertFalse(hasattr(result, 'Email'))
def connect():
    c = SforceEnterpriseClient(environ.get('SF_WSDL_PATH'))
    c.login(environ.get('SF_LOGIN'), environ.get('SF_PWD'), environ.get('SF_TOKEN'))
    
    return c
 def setUp(self):
   if self.h is None:
     self.h = SforceEnterpriseClient('../enterprise.wsdl.xml')
     self.h.login(test_config.USERNAME, test_config.PASSWORD, test_config.TOKEN)
class SforceEnterpriseClientTest(test_base.SforceBaseClientTest):
  wsdlFormat = 'Enterprise'
  h = None

  def setUp(self):
    if self.h is None:
      self.h = SforceEnterpriseClient('../enterprise.wsdl.xml')
      self.h.login(test_config.USERNAME, test_config.PASSWORD, test_config.TOKEN)

  def testSearchOneResult(self):
    result = self.h.search('FIND {Single User} IN Name Fields RETURNING Lead(Name, Phone, Fax, Description, DoNotCall)')

    self.assertEqual(len(result.searchRecords), 1)
    self.assertEqual(result.searchRecords[0].record.Name, 'Single User')
    self.assertTrue(isinstance(result.searchRecords[0].record.DoNotCall, bool))
    # make sure we get None and not ''
    self.assertFalse(hasattr(result.searchRecords[0].record, 'Description'))


  def testSearchManyResults(self):
    result = self.h.search(u'FIND {Joë Möke} IN Name Fields RETURNING Lead(Name, Phone, Company, DoNotCall)')

    self.assertTrue(len(result.searchRecords) > 1)
    for searchRecord in result.searchRecords:
      self.assertEqual(searchRecord.record.Name, u'Joë Möke')
      self.assertEqual(searchRecord.record.Company, u'你好公司')
      self.assertTrue(isinstance(result.searchRecords[0].record.DoNotCall, bool))

  def testUpdateOneFieldToNull(self):
    self.setHeaders('update')

    (result, lead) = self.createLead(True)

    lead.fieldsToNull = ('Email')
    lead.Email = None

    result = self.h.update(lead)
    self.assertTrue(result.success)
    self.assertEqual(result.id, lead.Id)

    result = self.h.retrieve('FirstName, LastName, Company, Email', 'Lead', (lead.Id))
    self.assertEqual(result.FirstName, u'Joë')
    self.assertEqual(result.LastName, u'Möke')
    self.assertEqual(result.Company, u'你好公司')
    self.assertFalse(hasattr(result, 'Email'))

  def testUpdateTwoFieldsToNull(self):
    self.setHeaders('update')

    (result, lead) = self.createLead(True)

    lead.fieldsToNull = ('FirstName', 'Email')
    lead.Email = None
    lead.FirstName = None

    result = self.h.update(lead)
    self.assertTrue(result.success)
    self.assertEqual(result.id, lead.Id)

    result = self.h.retrieve('FirstName, LastName, Company, Email', 'Lead', (lead.Id))

    self.assertFalse(hasattr(result, 'FirstName'))
    self.assertEqual(result.LastName, u'Möke')
    self.assertFalse(hasattr(result, 'Email'))
def connect():
    c = SforceEnterpriseClient(environ.get("SF_WSDL_PATH"))
    c.login(environ.get("SF_LOGIN"), environ.get("SF_PWD"), environ.get("SF_TOKEN"))

    return c
def connect():
    c = SforceEnterpriseClient(environ.get('SF_WSDL_PATH'))
    c.login(environ.get('SF_LOGIN'), environ.get('SF_PWD'), environ.get('SF_TOKEN'))
    
    return c
def sfdc_connect(auth):
    sfpath = '%s/wsdl/enterprise-%s.wsdl.xml' % (os.getcwd(), auth['database'])
    db = SforceEnterpriseClient(sfpath)
    db.login(auth['username'], auth['password'], '')
    return db
def connect():
    c = SforceEnterpriseClient(SF_WSDL_PATH)
    c.login(SF_LOGIN, SF_PWD, SF_TOKEN)
    
    return c
Beispiel #13
0
		    except:
			pass

		    if not o.get("name") in lastTime:
			lastTime[o.get("name")] = 864000

		    qry = "SELECT " + collist + " FROM " + o.get("name") + " WHERE " + timefield + " >= " + soql_format('e2gtime', lastTime[o.get("name")] ) + " ORDER BY " + timefield + limitfield

                    query.insert(k, qry)
		    tables.insert(k, o.get("name") )

		    k += 1

    flogger.info("Instantiating connection to SFDC API")

    h = SforceEnterpriseClient(os.path.join(sys.path[0], '..', 'local', settings["wsdl"] ))
    h.login(settings["username"], settings["password"], settings["token"])

    flogger.info("Instantiating per-object log files")

    f = {}

    for q in tables:
        f[q] = logging.getLogger(q)
        f[q].setLevel(logging.DEBUG)
        handler = logging.handlers.RotatingFileHandler("/".join([settings["log_path"], q]), maxBytes=52428800, backupCount=20)
        g = logging.Formatter("%(message)s")
        handler.setFormatter(g)
        handler.setLevel(logging.INFO)
        f[q].addHandler(handler)
Beispiel #14
0
import os, sys
import pdb
proj_dir = os.path.abspath(os.path.dirname(__file__))
packages_dir = os.path.join(proj_dir, 'packages')
sys.path.append(packages_dir)


from sforce.enterprise import SforceEnterpriseClient
h = SforceEnterpriseClient('wsdl.jsp.xml')
h.login('*****@*****.**', '303618', 'hSyF4Sgd2AEp1yt7URAb1S2yD')

def get_connection(): 
    h = SforceEnterpriseClient(settings.SFORCE_WSDL_PATH)
    h.login(settings.SFORCE_USER, settings.SFORCE_PASSWORD, settings.SFORCE_TOKEN)
    return h
Beispiel #16
0
def login():
    h = SforceEnterpriseClient('%s/skyhigh/wsdl/skyhigh_salesforce_enterprise.wsdl.xml' % settings.STATIC_ROOT)
    h.login(settings.SERVICE_CLOUD_USERNAME, settings.SERVICE_CLOUD_PASSWORD, settings.SERVICE_CLOUD_SECURITY_TOKEN)
    
    return h