Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4268334
Creating diff from python using Conduit
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
cspeckmim
Mar 24 2017, 2:11 PM
2017-03-24 14:11:24 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
Creating diff from python using Conduit
View Options
# Create a raw diff in Phabricator
post_data = {
'api.token': phab_api_token,
'diff': diff,
'repositoryPHID': respository_phid
}
try:
diff_phid = execute_conduit_api("differential.createrawdiff", post_data)["result"]["phid"]
ui.debug("STRINGS: Created diff of properties changes, PHID is %s" % diff_phid)
except Exception as err:
ui.warn("STRINGS: Failed to create diff of properties changes: %s" % err)
return True
def execute_conduit_api(api_method, post_data):
output_buffer = StringIO() # Initializes a string buffer that will be used to capture the
# returned JSON string from the Curl command
postfields = urlencode(post_data) # The form data we provide to Phabricator must be urlencoded -
# that is, formatted so that it can be transmitted as a URL.
c = pycurl.Curl() # Initialize a Curl object that will be used to send the data
c.setopt(c.URL, base_url + '/api/' + api_method) # Sets the URL that data should be sent to
c.setopt(c.POSTFIELDS, postfields) # Sets the request method to POST, Content-Type header to
# application/x-www-form-urlencoded, and data in request body.
c.setopt(c.WRITEFUNCTION, output_buffer.write) # Write output to the StringIO buffer
c.perform()
c.close()
parsed_json = json.loads(output_buffer.getvalue())
if parsed_json["error_code"] is not None:
raise Exception("PHAB: %s, %s" % (parsed_json["error_code"], parsed_json["error_info"]))
return parsed_json
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
567862
Default Alt Text
Creating diff from python using Conduit (1 KB)
Attached To
Mode
P2032 Creating diff from python using Conduit
Attached
Detach File
Event Timeline
Log In to Comment