Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python2
import os
import sys
import StringIO
import psycopg2
import psycopg2.extensions
from optparse import OptionParser
from ConfigParser import SafeConfigParser
try:
[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = False
db_port = False
db_user = <db_user>
db_password = <db_password>
addons_path = /opt/odoo10/addons,/opt/<your_project_folder>
def authenticate(self,hostname, client_id, client_secret, username, password):
uri_path = '/oauth/token'
headers = {'Content-Type':'application/x-www-form-urlencoded'}
params = {'grant_type':'password', 'client_id':client_id, 'client_secret':client_secret,
'username':username, 'password':password}
http = httplib.HTTPSConnection(hostname)
http.request('POST', uri_path, urllib.parse.urlencode(params), headers=headers)
response = http.getresponse()
def create_new_user_id(self,token,zone_id):
password = get_random_password_string(13)
self.email = "[email protected]"
self.firstname = "firstname"
self.lastname = "lastname"
self.company_name = "company_name"
userdata = {
"Email": self.email,
"FirstName":self.firstname,
"LastName":self.lastname,
def create_sharefile_link(self):
self.create_user_sharelink()
config_obj = self.env['ir.config_parameter']
parent_id = config_obj.sudo().get_param('sharefile.sharefile_parent_id') # for Odoo
parent_id = "123"
folder_name = "Test"
folder_desc = "Test desc"
hostname, username, password, client_id, client_secret = self.get_config_data()
def get_folder_with_query_parameters(self,token, item_id,folder_name):
uri_path = '/sf/v3/Users/AllSharedFolders'
headers = self.get_authorization_header(token)
http = httplib.HTTPSConnection(self.get_hostname(token))
http.request('GET', uri_path, headers=headers)
response = http.getresponse()
if response.status == 200:
data = json.loads(response.read())
def download_item():
uri_path = "/sf/v3/Items(%s)/Download" % (item_id)
http = httplib.HTTPSConnection(self.get_hostname(token))
http.request("GET", uri_path, headers=self.get_authorization_header(token))
response = http.getresponse()
location = response.getheader("location")
if location:
urllib.request.urlretrieve(location, "/home/Downloads/item.zip")
FROM ubuntu:18.04
RUN apt-get update -y && \
apt-get install -y python3-pip python3-dev
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip3 install pika && \
FROM ubuntu:18.04
RUN apt-get update -y && \
apt-get install -y python3-pip python3-dev
RUN pip3 install pika
WORKDIR /app
COPY . /app
version: '3.8'
services:
rabbitmq:
image: 'rabbitmq:3-management'
ports:
- '5672:5672'
- '15672:15672'