Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. The MIT License (MIT)
  5. Copyright (c) 2014 sinfonier-project
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. """
  22.  
  23. import basesinfonierdrain
  24. import requests
  25. import urllib
  26. import os
  27. import csv
  28. import requests
  29. import json
  30. from base64 import b64encode
  31.  
  32. class OrientDBCreatingEdge(basesinfonierdrain.BaseSinfonierDrain):
  33.  
  34. def __init__(self):
  35.  
  36. basesinfonierdrain.BaseSinfonierDrain().__init__()
  37.  
  38. def userprepare(self):
  39.  
  40. self.raids = self.getParam("raids")
  41. self.name_database = self.getParam("name_database")
  42. # catching url_database = "url:port". Usually port = 2480
  43. self.url_database = self.getParam("url_database")
  44. if self.existsField("user")
  45. self.user = self.getParam("user")
  46. if self.existsField("password")
  47. self.password = self.getParam("password")
  48.  
  49. def userprocess(self):
  50.  
  51. try:
  52. # creating headers
  53. user_password = self.user + ":" + self.password
  54. user_and_pass = b64encode("user_password").decode("ascii")
  55. headers = { 'Authorization' : 'Basic %s' % user_and_pass }
  56.  
  57. # creating Edge POST with SQL
  58. content = { "class":ASDASD, "command":"create edge ASDASD from (select from ASDASD where @rid=ASDASD) to (select from ASDASD where @rid=ASDASD)" }
  59.  
  60. except Exception, ex:
  61. self.log("ERROR is comming : " + str(ex))
  62.  
  63. OrientDBCreatingEdge().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement