GithubHelp home page GithubHelp logo

superfell / beatbox Goto Github PK

View Code? Open in Web Editor NEW
123.0 12.0 60.0 132 KB

Beatbox is an easy to use Python Library for accessing the Salesforce.com API

Home Page: http://www.pocketsoap.com/beatbox/

License: GNU General Public License v2.0

Python 99.50% Shell 0.50%

beatbox's Introduction

Beatbox Build Status

is a minimal dependency python library for accessing the salesforce.com web services API.

Its primary dependency is on xmltramp, an xml parser library that exposes access to the xml document in an easy to use manner.

Beatbox is released under the GPL v2.

http://www.pocketsoap.com/beatbox/

Beatbox requires Python 2.7.9 or later or Python 3.4 or later. Thanks hynekcer for the Python 3 support!

Installation (Python 3)

The Beatbox3 PyPI is stale and not Python 3 compatible (refer to issue #46).

To ensure that you are using the latest python3 compatible version please install using pip syntax:

Command line:

pip install -e git+https://github.com/superfell/Beatbox@master#egg=beatbox

In requirements.txt:

-e git+https://github.com/superfell/Beatbox@master#egg=beatbox

About Salesforce API retirement

During 2022 Salesforce are planning to retire API versions v7 through v20. Also planned for 2023 is the retirement of versions v21 through v30. If you're on an older version of Beatbox you'll need to update to the latest (which uses API v36) in order for your integrations to continue to work. You may also need to update code for API calls where the response structure has changed from the version you're currently using e.g. DescribeGlobal changed significantly somewhere around API v16.

About TLS 1.2 Support

During 2016 Salesforce plans to disable TLS 1.0 support on their service. In order for Beatbox to continue working you need to use a python environment that supports TLS 1.2. To do that you need to use Python 2.7.9 (or any newer 2.x version) and your OpenSSL version needs to be 1.0.1 or greater. You can run python --version to check your python version and python -c "import ssl; print ssl.OPENSSL_VERSION" to check the version of OpenSSL that python is using.

Note that if you're on OSX, its bundled with an older version of openSSL than is required. If you see an error similar to ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure or UNSUPPORTED_CLIENT: TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https. you need to update your python and/or OpenSSL versions.

About PyPi/Beatbox

This version of Beatbox is not fully compatible with the version at https://pypi.python.org/pypi/beatbox/32.1 See issue #43 for all the details.

beatbox's People

Contributors

baxter001 avatar bmcgue avatar danieldsj avatar enkidulan avatar hynekcer avatar mstevens avatar nate-opti avatar superfell avatar tecktron avatar tltx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beatbox's Issues

Unable to clear custom field value

I'm trying to update (using the update method) a custom field value to set it to Null/Empty on a Contact object but this doesn't seem to work. I've tried setting the value to None, '' (empty string), 'null' and both failed to clear or reset the value for the field (by looking in the Contact profile in the Salesforce UI).

Is there a way to set a custom field value to Null? Is this even supported?

Thanks

gzipRequest not working for python3

The default gzipRequest is set to True, but it doesn't work in python3. Got an error TypeError: string argument expected, got 'bytes' when executing self.fileobj.write(b'\037\213' in file gzip.py.

In python3, BytesIo should be used instead of StringIO, and thus a potential fix would be changing self.__buf = StringIO("") to self.__buf = BytesIO(b"") in file beatbox.py at line 283

Query Time Out

I keep getting a Query Time Out error when trying to bring back the whole table of "Case History" not sure if the api used in Beatbox is not the right place. Do I need to investigate the bulk api? Or another way to troubleshoot?

beatbox.py: IndentationError

Trying to install Beatbox from this repository, I get:

Running setup.py install for beatbox
Sorry: IndentationError: unexpected indent (beatbox.py, line 39)

support in setting the batchSize of the service

Hello,
Is it possible to update the batchsize attribute of the service?
In addition I've noticed that in some tables (Oportunity,Task) the chunk size is different than the default value 500 and the data is being pulled in chunks of 200. Can it be changed?

Thanks,
Itay

Python 3.6.7 - wrong output

Result of commands executed with beatbox on python 3.6 is a string combined from all fields, for inscante AccountStatusNameOK etc.
In python 2.7 result is returned as list.

Add unit tests

really need some unit tests, especially now that we're supporting both python 2 & 3.

Once we have tests, should also setup travis to run them

How to pull the data from method describeGlobal()

Hi,

What is the required namespace for retrieving the returned objects from this method?
When I try the following (as explained in http://www.pocketsoap.com/beatbox/) :
sf = beatbox._tPartnerNS
svc = beatbox.Client()
svc.login(username, password)
res_tables = svc.describeGlobal()
tables_list = res_tables[sf.types:]

I don't get any results in tables_list.
Should I address another field in sf?

Thanks in advance!
Itay

Salesforce Refresh Instances

Salesforce going to do overall change at the 3rd of Dec
what they called - Refresh Instances.

Is it going to affect the use of Beatbox?
Do we need to change of upgrade something>

Thanks!

Version of Beatbox in Pypi is incorrect?

The version of Beatbox in Pypi is 20.0 http://pypi.python.org/pypi/beatbox/20.0

The version in this repository is 0.94.

The code seems to have been heavily re factored between these two versions.

The code within 20.0 hsa a copyright of 2006, while the one here is from 2006-2012

Which is the correct version to use? If it is 0.94, why isn't this version in Pypi? Why did the version number drop from 20.0 to 0.94? If it is 20.0, why is this repo out of date?

bulkify create, update, upsert, delete, or undelete

Forgive me if this isn't the appropriate avenue to post this comment.

Is it possible to "bulkify" any of the create, update, upsert, delete, or undelete methods to avoid the following error: "EXCEEDED_ID_LIMIT: record limit reached. cannot submit more than 200 records into this call"

I know that Lexi Loader handles gracefully. I have created a wrapper around Beatbox to split my sObjects into lists of 200 or less as a workaround.

retrieve method fails if only one record found

I use demo.py for tests. Your original current source fails on an empty Salesforce instance or if no Account "New Account" has been present before running the demo.

Traceback (most recent call last):
  File "demo.py", line 235, in <module>
    demo.retrieve()
  File "demo.py", line 154, in retrieve
    print str(acc[beatbox._tSObjectNS.Id]) + " : " + str(acc[beatbox._tSObjectNS.Name])
  File "/home/.../Beatbox/xmltramp.py", line 143, in __getitem__
    raise KeyError, n
KeyError: ('urn:sobject.partner.soap.sforce.com', 'Id')

It is because beatbox.Client.retrive returns directly one xmltramp.Element instead of a list of length 1.

The backward compatible solution is to modify only the demo.py so that it is tested if the result is a list or an Element :

     def retrieve(self):
         print("\nretrieve")
         accounts = svc.retrieve("id, name", "Account", self.__theIds)
+        if not beatbox.islst(accounts):
+            accounts = [accounts]
         for acc in accounts:

... but this is not a demo of advisable clean code.
A more natural solution would be to return a list of elements by beatbox.Client.retrieve if the ids parameter is a list, otherwise to return an element if an Id is used directly without list.

         def retrieve(self, fields, sObjectType, ids):^M
                 return RetrieveRequest(self.__serverUrl, self.sessionId, fields, sObjectType, ids
-                                       ).post(self.__conn)
+                                       ).post(self.__conn, islst(ids))

The best solution is probably to add a retrive method to IterClient class and also to write an example with IterClient to the documentation because that class is very useful. It will be both natural and backward compatible. What do you mean?

init of beatbox.Client()

Have to use beatbox._beatbox.Client() to get a client.

Reproduced on Windows running Python 2.7.9, Ubuntu running Python 2.7.6, beatbox v32.1 on both, installed via pip.

>>> import beatbox
>>> svc = beatbox.Client()

Traceback (most recent call last):
  File "<pyshell#44>", line 1, in <module>
    svc = beatbox.Client()
AttributeError: 'module' object has no attribute 'Client'
>>> svc = beatbox._beatbox.Client() #This works
>>> 

can't select fields which contains the word 'Address'

Hello,
When I'm trying to pull Address fields (ShippingAddress, BillingAddress, Address etc.) from any table in Salesforce I run into an error in function query in module python_client (the failure is in function _extractRecord which is being called by function query).

Is that a known issue? Is it because of the name Address? How should I pull those fields?
Thanks a lot in advance!
Itay

Support for iterable versions of the standard calls.

I have a small collection of monkey patches I put into our internal version of beatbox to add methods that return iterators for the collection returning calls that wrap the need to use queryMore, and alternate forms of upsert,insert and delete that take generators and chunk them into blocks of size batchSize.

How would you feel about a PR for adding these methods onto the Client or an iterClient subclass?

No longer outputting json like legacy 2.7 version

I'm currently in transition changing our code from 2.7 to 3.7 and I found that beatbox required an update. I updated, it and fixed the calls, but now I'm getting response of a full string, instead of a json list. I use to have a code that did this.

row = {}
response = json.dumps(response)
jsonParser = json.loads(response)
row['Status'] = "Success"
row['IDNumber'] = jsonParser["IDNumber"]

But looks like the output is only showing only full string plus a true boolean at the front of it.
I looked at issue 51, and attempted using the code given by superfell, but the sorting of the columns was completely out of wack, rec[0] had true,rec[1] were empty, and rec[2] had the full string, rec[3] had the third column, rec[4] had the 4th column.

FullString example output:
AccountIDAccountNameIDNumberStatus

Getting more results than 500

I attempted to increase the batchsize, but I'm trying to get all the values since the values could increase or decreased based on he batch size. I attempted to use queryAll or querymore. But they both failed. I also attempted to use the following documentation, but doesn't seem to function with this version of beatbox. Can you provide me some insight on how I can get all the rows to show up.
http://tomhayden3.com/2013/08/04/salesforce-python/

Exporting data slow compared to SoqlXplorer

Hi,

I've noticed that SoqlXplorer is generally about 2-3 times faster at saving query results than the export.py demo - but I also see a large variance in times for both so it could just be transient network conditions or some other factor. Neither use much CPU or bandwidth so I'm wondering if there's something at the Salesforce end (maybe a different API?) that might explain the difference.

Thanks.

GPL versions

Hi.

Just wondering which version of the GPL applies, the README just says "Beatbox is released under the GPL."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.