def sample19(request): clientId = request.POST.get('client_id') privateKey = request.POST.get('private_key') sourceFileId = request.POST.get('sourceFileId') targetFileId = request.POST.get('targetFileId') callbackUrl = request.POST.get('callbackUrl') basePath = request.POST.get('server_type') # Checking required parameters if IsNotNull(clientId) == False or IsNotNull(privateKey) == False or IsNotNull(sourceFileId) == False or IsNotNull(targetFileId) == False: return render_to_response('__main__:templates/sample19.pt', { 'error' : 'You do not enter all parameters' }) ### Create Signer, ApiClient and Annotation Api objects # Create signer object signer = GroupDocsRequestSigner(privateKey) # Create apiClient object apiClient = ApiClient(signer) # Create ComparisonApi object compare = ComparisonApi(apiClient) compare.basePath = basePath # complare files info = compare.Compare(clientId, sourceFileId, targetFileId, callbackUrl) if info.status == "Ok": # Create AsyncApi object async = AsyncApi(apiClient) async.basePath = basePath time.sleep(5) # get job info jobInfo = async.GetJobDocuments(clientId, info.result.job_id) # construct result iframe = '' if jobInfo.status == "Ok": # Generation of iframe URL using jobInfo.result.outputs[0].guid if basePath == "https://api.groupdocs.com/v2.0": iframe = '<iframe src="https://apps.groupdocs.com/document-viewer/embed/' + jobInfo.result.outputs[0].guid + '?frameborder="0" width="720" height="600"></iframe>' elif basePath == "https://dev-api.groupdocs.com/v2.0": iframe = '<iframe src="https://dev-apps.groupdocs.com/document-viewer/embed/' + jobInfo.result.outputs[0].guid + '?frameborder="0" width="720" height="600"></iframe>' elif basePath == "https://stage-api.groupdocs.com/v2.0": iframe = '<iframe src="https://stage-apps.groupdocs.com/document-viewer/embed/' + jobInfo.result.outputs[0].guid + '?frameborder="0" width="720" height="600"></iframe>' # If request was successfull - set variables for template return render_to_response('__main__:templates/sample19.pt', {'userId' : clientId, 'privateKey' : privateKey, 'sourceFileId' : sourceFileId, 'targetFileId' : targetFileId, 'callbackUrl' : callbackUrl, 'iframe': iframe }, request=request)
def sample20(request): clientId = request.POST.get('clientId') privateKey = request.POST.get('privateKey') resultFileId = request.POST.get('resultFileId') basePath = request.POST.get('basePath') # Checking required parameters if not clientId or not privateKey or not resultFileId: return render_to_response('__main__:templates/sample20.pt', dict(error='You do not enter all parameters')) ### Create Signer, ApiClient and Annotation Api objects # Create signer object signer = GroupDocsRequestSigner(privateKey) # Create apiClient object apiClient = ApiClient(signer) # Create ComparisonApi object compare = ComparisonApi(apiClient) if not basePath: basePath = 'https://api.groupdocs.com/v2.0' compare.basePath = basePath # get changes info = compare.GetChanges(resultFileId) # construct table results result = None if info.status == "Ok": result = "<table class='border'>" result += "<tr><td><font color='green'>Change Name</font></td><td><font color='green'>Change</font></td></tr>" if info.result.changes is not None: for item in info.result.changes: for key in item.__dict__: if key != 'swaggerTypes': if type(item.__dict__[key]).__name__ == 'instance': for value in item.__dict__[key].__dict__: if value != "swaggerTypes": result += "<tr><td>" + value + "</td><td>" + unicode( item.__dict__[key].__dict__[value]) + "</td></tr>" else: result += "<tr><td>" + key + "</td><td>" + unicode(item.__dict__[key]) + "</td></tr>" result += "<tr style='background: #808080'><td></td><td></td></tr>" result += "</table>" # If request was successful - set variables for template return render_to_response('__main__:templates/sample20.pt', {'userId': clientId, 'privateKey': privateKey, 'resultFileId': resultFileId, 'result': result}, request=request)
def sample20(request): clientId = request.POST.get('client_id') privateKey = request.POST.get('private_key') resultFileId = request.POST.get('resultFileId') basePath = request.POST.get('server_type') # Checking required parameters if IsNotNull(clientId) == False or IsNotNull(privateKey) == False or IsNotNull(resultFileId) == False: return render_to_response('__main__:templates/sample20.pt', { 'error' : 'You do not enter all parameters' }) ### Create Signer, ApiClient and Annotation Api objects # Create signer object signer = GroupDocsRequestSigner(privateKey) # Create apiClient object apiClient = ApiClient(signer) # Create ComparisonApi object compare = ComparisonApi(apiClient) if basePath == "": basePath = 'https://api.groupdocs.com/v2.0' compare.basePath = basePath # get changes info = compare.GetChanges(clientId, resultFileId) # construct table results result = "" if info.status == "Ok": result = "<table class='border'>" result += "<tr><td><font color='green'>Change Name</font></td><td><font color='green'>Change</font></td></tr>" if info.result.changes is not None: for item in info.result.changes: for key in item.__dict__: if key != 'swaggerTypes': if type(item.__dict__[key]).__name__ == 'instance': for value in item.__dict__[key].__dict__: if value != "swaggerTypes": result += "<tr><td>" + value + "</td><td>" + unicode(item.__dict__[key].__dict__[value]) + "</td></tr>" else: result += "<tr><td>" + key + "</td><td>" + unicode(item.__dict__[key]) + "</td></tr>" result += "<tr bgcolor='#808080'><td></td><td></td></tr>" result += "</table>" # If request was successfull - set variables for template return render_to_response('__main__:templates/sample20.pt', {'userId' : clientId, 'privateKey' : privateKey, 'resultFileId' : resultFileId, 'result' : result}, request=request)
for the_file in os.listdir(currentDir + '/../downloads'): file_path = os.path.join(currentDir + '/../downloads', the_file) try: #Delete file from folder os.unlink(file_path) except Exception, e: print e ### Create Signer, ApiClient and Annotation Api objects # Create signer object signer = GroupDocsRequestSigner(privateKey) # Create apiClient object apiClient = ApiClient(signer) # Create ComparisonApi object compare = ComparisonApi(apiClient) api = StorageApi(apiClient) if basePath == "": basePath = 'https://api.groupdocs.com/v2.0' #Set base path api.basePath = basePath compare.basePath = basePath if url != "" or target_url != "": if url != "": try: # Upload file to current user storage using entere URl to the file upload = api.UploadWeb(clientId, url) sourceFileId = upload.result.guid except Exception, e: return render_to_response('__main__:templates/sample19.pt',