def main():
    # access_token = connect_and_get_access_token()
    # print(access_token)
    egnyte_connect = egnyte_connector()
    eg_config = utils.config_parser()
    access_token = eg_config.get('egnyte', 'access_token')
    # Connect to egnyte using domain and access token
    client = egnyte.EgnyteClient({
        "domain": "xoriant.egnyte.com",
        "access_token": access_token
    })
 def get_egnyte_client():
     # access_token = egnyte_connector.get_access_token_from_egnyte()
     egnyte_client_obj = egnyte_connector.egnyte_client
     if egnyte_client_obj is not None:
         logger.info('Already connected to Egnyte')
     else:
         access_token = egnyte_connector.get_access_token_from_es()
         # access_token = egnyte_connector.get_access_token_from_config()
         config = utils.config_parser()
         domain = config.get('egnyte', 'domain')
         try:
             client = egnyte.EgnyteClient({
                 "domain": domain,
                 "access_token": access_token
             })
             logger.info("Successfully connected to Egnyte")
             return client
         except Exception as e:
             logger.info(e)
             return e
Beispiel #3
0
if "client_id" not in config:
    config["client_id"] = "zxuez95f5utrrf7v2ukyex6y"
    _updates = True

if "domain" not in config:
    config["domain"] = "camsys"
    _updates = True

if "time_between_requests" not in config:
    config["time_between_requests"] = 1
    _updates = True

if _updates:
    egnyte.configuration.save(config)

client = egnyte.EgnyteClient(config)


def _folder_to_path(f):
    if isinstance(f, egnyte.resources.Folder):
        return f.path
    if isinstance(f, egnyte.resources.File):
        return f.path
    return f


def pth(*arg):
    return "/".join(_folder_to_path(f)
                    for f in arg).replace('//', '/').replace('\\', '/')

Beispiel #4
0
    user_restrict = user_restrict.replace(' ', '').split(',')
    restrict_date = datetime.strptime(restrict_date, '%Y-%m-%d')

data = {
    'client_id': 'cq2hfa6gzzzgy29fddkg64jm',
    'username': username,
    'password': password,
    'grant_type': 'password'
}
get_access_token = requests.post('https://' + domain +
                                 '.egnyte.com/puboauth/token',
                                 data=data)
access_token = get_access_token.json()['access_token']
fs_api = 'https://' + domain + '.egnyte.com/pubapi/v1/fs'
client = egnyte.EgnyteClient({
    "domain": domain + ".egnyte.com",
    "access_token": access_token
})


def recursive_folder(path):
    try:

        uri = fs_api + path

        folder = client.GET(requote_uri(uri))
        # folder = client.GET(fs_api + urllib.quote(path.encode('utf8')))
        folder_attributes = folder.json()

        # if folder_attributes.has_key('files'):
        if "files" in folder_attributes:
            print(type(folder_attributes['files']))
Beispiel #5
0
import egnyte
from urllib.parse import urlencode
import time
from apscheduler.schedulers.background import BlockingScheduler
from pytz import utc

scheduler = BlockingScheduler()


outdir = "pdfs"
sess = requests.session()

ConnectionID = ""
ConnectionToken = ""

client = egnyte.EgnyteClient({"domain": "ccbfiles.egnyte.com", "access_token": "axdx2jem4rbymyn75anqzt62"})

filenames = []

def get_files_list():
    """
    Get file name list of egnyte
    """
    global filenames
    folder = client.folder("/Shared/OmniSign/pdfs")
    folder.list()
    for file_obj in folder.files:
        filenames.append(file_obj.name)


def login():