Start-AzureSqlDatabaseImport completed - azure-sql-database

Is there a any way to know when a Start-AzureSqlDatabaseImport command has finished importing? The command returns pretty much immediately, but i can't find a way to check when the import has actually completed into my existing database.

Start-AzureSqlDatabaseImport starts an import which is an async operation. If you want to check the status of an import you will need to store the import request in a variable. See below:
$importRequest = Start-AzureSqlDatabaseImport -SqlConnectionContext $SqlCtx -StorageContainer $Container -DatabaseName $DatabaseName -BlobName $BlobName
After you store the request in a variable you can then use the Get-AzureSqlDatabaseImportExportStatus cmdlet to track the status of the import. See below:
Get-AzureSqlDatabaseImportExportStatus -Request $importRequest
Hope this helps!

Related

How to call a the python code when a new message is delivered from telethon API

How can I call some Python code when a new message is delivered from the Telethon API? I need to run the code all the day so that I can do my processing from Python code.
How to use this? #client.on(events.NewMessage(chats=channel, incoming=True))
Do I need run the scheduler to check this?
I am using history = client(GetHistoryRequest) method.
First Steps - Updates in the documentation greets you with the following code:
import logging
logging.basicConfig(format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s',
level=logging.WARNING)
from telethon import TelegramClient, events
client = TelegramClient('anon', api_id, api_hash)
#client.on(events.NewMessage)
async def my_event_handler(event):
if 'hello' in event.raw_text:
await event.reply('hi!')
client.start()
client.run_until_disconnected()
Note you can "call" any Python code inside my_event_handler. It also shows how #client.on() is meant to be used. Note there is no need for a scheduler.
I am using history = client(GetHistoryRequest) method.
As a side note this is raw API which is discouraged if a friendly alternative, like client.get_messages, exists.

de.hybris.platform.jalo.Jalo SystemException: no attribute ImpEx Import CronTab.sendEmail OnFailure found[HY--1]

Hybris[Impex script import] :
Getting below exception while importing the impex script.
de.hybris.platform.jalo.Jalo SystemException: no attribute ImpEx Import CronTab.sendEmail OnFailure found[HY--1]
This issue occurs when we are using the db dump for the first time.
I have resolved this. Need to do system update by selecting the all extensions in Hac.
It worked.

No such table Django Database

So I created a model for storing credentials from Gmail users.
I wanted to make migrations but it says that there is no such table:
django.db.utils.OperationalError: no such table: mainApp_credentialsmodel
My models:
from django.db import models
# Create your models here.
from django.contrib.auth.models import User
from django.db import models
import json
class CredentialsModel(models.Model):
id = models.ForeignKey(User, primary_key=True,on_delete=models.CASCADE)
credential = models.CharField(max_length=1000)
Calling that model for checking authorization:
SCOPES = 'https://www.googleapis.com/auth/gmail.readonly'
store = CredentialsModel.objects.all()
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('mainApp/client_secret.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
python manage.py makemigrations
If that error keep happening, check your migrations folder and check the files inside. Also check If your database is online, in case you have a database online, I've got this problem last week, but it was a problem with azure.
In last case I would create the table (model) again, changing the name to something similar, but If you have a significant amount of data in that table, then I think you can't do that.
It looks like your authorization code - including the query on CredentialsModel - is at module level. This means it runs when the module is imported, which happens before the migration has had a chance to run.
You must ensure that any database-accessing code is inside a function or method and is not invoked globally.

How to use setBodyContent(HttpBodyContent) in Katalon

I have been trying to update our test management API once the Katalon test has completed running.
We are using Adaptavist Test Management in JIRA. I am not trying to update the Katalon JIRA add-on by the way.
The API call, for Adaptavist, needs to be a POST and have a body message of items like the example {"projectKey": "FVS", "testCaseKey": "FVS-T1", "status": "Pass", "environment": "DEV"}
I would eventually replace these items with the Katalon test result variables as appropriate.
I have created a Service Call in the Object Repository which deals with auth settings, this works fine if I test the request in the editor with these sample values.
When I come to add the script in the Test Case itself I am struggling to get it to work, let alone replace the variables with the actual values.
I current have this :
//run test
WebUI.openBrowser('')
WebUI.navigateToUrl(GlobalVariable.MainURL)
WebUI.verifyElementClickable(findTestObject('img_img-responsive_1'))
WebUI.verifyElementClickable(findTestObject('img_img-responsive_2'))
WebUI.verifyElementClickable(findTestObject('img_img-responsive_3'))
WebUI.closeBrowser()
//update JIRA
RequestObject getJIRAUpdateObject = (RequestObject)findTestObject('Web Service
Calls/Update JIRA')
String vsRequestBody = '{"projectKey": "FVS", "testCaseKey": "FVS-T1",
"status": "Pass", "environment": "DEV"}';
body = getJIRAUpdateObject.setHttpBody(vsRequestBody)
WS.sendRequest(getJIRAUpdateObject)
I also have the following additional imports
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.testobject.RequestObject
Now in the script editor, I am told that setHttpBody is now depreciated in Katalon version 5.4+ (I am using 5.4.1) and I should use setBodyContent(HttpBodyContent) instead, but when I look at the API documentation for this, I cannot work out the syntax of how I am supposed to use this instead.
Does anyone know how I should change the code, or have examples of how I need to change the above code to use this new method ??
Any help is much appreciated.
As answered on the Katalon forum:
In your case, the body content is text body then the suitable implementation should be:
import com.kms.katalon.core.testobject.impl.HttpTextBodyContent //for text in body
import com.kms.katalon.core.testobject.impl.HttpFileBodyContent //for file in body
import com.kms.katalon.core.testobject.impl.HttpFormDataBodyContent //for form data body
import com.kms.katalon.core.testobject.impl.HttpUrlEncodedBodyContent //for URL encoded text body
setBodyContent(new HttpTextBodyContent(your_text))
(API docs for HttpBodyContent implementation.)

getting result from a function running "deferToThread"

I have recently started working on twisted not much familiar with its functions.I have a problem related to "deferToThread" method...my code is here to use this method
from twisted.internet.threads import deferToThread
from twisted.internet import reactor
results=[]
class Tool(object):
def exectool(self,tool):
# print "Test Class Exec tool running..........."
exec tool
return
def getResult(self,tool):
return results.append(deferToThread(self.exectool, tool))
to=Tool()
to.getResult(tools)
f=open(temp).read()
obj_tool=compile(f, 'a_filename', 'exec')
[ at 0x8ce7020, file "a_filename", line 1>, at 0x8cd4e30, file "a_filename", line 2>]
I am passing tools one by one in getResults() method it executs successfully & prints the results what script written in the file objects.
I have to store the result of tools executing in some variable so that I can save it in database.How to achieve this cause when i call re=to.getResult(tools) and print "re" it prints none.
I HAVE TO STORE ITS RESULTS IN DATABASE? IS THERE SOMETHING I CAN DO?
thanx in advance
There are two problems here.
First, deferToThread will not work if you never start the reactor. Hopefully this code snippet was actually extracted from a larger Twisted-using application where the reactor is running, so that won't be an actual problem for you. But you shouldn't expect this snippet to work unless you add a reactor.run() call to it.
Second, deferToThread returns a Deferred. The Deferred fires with the result of the callable you passed in. This is covered in the API documentation. Many APIs in Twisted return a Deferred, so you might want to read the documentation covering them. Once you understand how they work and how to use them, lots of things should be quite a bit easier.