I'm not able to pass the user input into JQL query? I've tried no of alternative but nothing works.
Here is the code.
project_name=raw_input("Please give the project name: ")
reporter_name=raw_input("Please provide the name of creator: ")
date_from=raw_input("Please provide the time interval for which you want issues: From ")
date_to=raw_input("Please provide the time interval for which you want issues: To ")"""
total_issues = jira.search_issues('project = %s AND reporter = %s AND created > %s and created < %s' % (projectname, reportername, datefrom, dateto))
print total_issues
It gives me: jira.exceptions.JIRAError
traceback (most recent call last):
File "jiradetailsizmirtomtom.py", line 27, in <module>
for i in jira.search_issues('project = project_name AND reporter = reporter_name AND created > date_from and created < date_to'):
File "/Library/Python/2.7/site-packages/jira/client.py", line 1747, in search_issues
issues = self._fetch_pages(Issue, 'issues', 'search', startAt, maxResults, search_params)
File "/Library/Python/2.7/site-packages/jira/client.py", line 397, in _fetch_pages
resource = self._get_json(request_path, params=page_params, base=base)
File "/Library/Python/2.7/site-packages/jira/client.py", line 2172, in _get_json
r = self._session.get(url, params=params)
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 150, in get
return self.__verb('GET', url, **kwargs)
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 146, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "/Library/Python/2.7/site-packages/jira/resilientsession.py", line 56, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError
Can we really pass variable to JQL query? Does JQL allows this?
Related
When trying to get information about a virtual machine, I am met with the following error:
Traceback (most recent call last):
File "/Users/shilpakancharla/Documents/function_app/WeedsMediaUploadTrigger/event_process.py", line 73, in <module>
vm_data, vm_status = get_azure_vm(key.RESOURCE_GROUP, key.VIRTUAL_MACHINE_NAME)
File "<decorator-gen-2>", line 2, in get_azure_vm
File "/usr/local/lib/python3.9/site-packages/retry/api.py", line 73, in retry_decorator
return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
File "/usr/local/lib/python3.9/site-packages/retry/api.py", line 33, in __retry_internal
return f()
File "/Users/shilpakancharla/Documents/function_app/WeedsMediaUploadTrigger/event_process.py", line 65, in get_azure_vm
vm_instance = compute_client.virtual_machines.get(resource_group_name,
File "/usr/local/lib/python3.9/site-packages/azure/mgmt/compute/v2019_12_01/operations/_virtual_machines_operations.py", line 641, in get
map_error(status_code=response.status_code, response=response, error_map=error_map)
File "/usr/local/lib/python3.9/site-packages/azure/core/exceptions.py", line 102, in map_error
raise error
azure.core.exceptions.ResourceNotFoundError: Operation returned an invalid status 'Not Found'
Does this mean that get() is not a valid function for compute_client.virtual_machines? It says that it is valid in the documentation, but I am not sure why this error is arising. This is my implementation, and I use the call vm_data, vm_status = get_azure_vm(key.RESOURCE_GROUP, key.VIRTUAL_MACHINE_NAME). I am confident that all my credentials are correct.
def get_access_to_virtual_machine():
subscription_id = key.SUBSCRIPTION_ID
credentials = DefaultAzureCredential(authority = AzureAuthorityHosts.AZURE_GOVERNMENT,
exclude_environment_credential = True,
exclude_managed_identity_credential = True,
exclude_shared_token_cache_credential = True)
client = KeyClient(vault_url = key.VAULT_URL, credential = credentials)
compute_client = ComputeManagementClient(credentials, subscription_id,
base_url = 'https://portal.azure.us')
return compute_client
def get_azure_vm(resource_group_name, virtual_machine_name):
compute_client = get_access_to_virtual_machine()
vm_instance = compute_client.virtual_machines.get(resource_group_name,
virtual_machine_name)
vm_status = vm_instance.instance_view.statuses[1].display_status
return vm_instance, vm_status
You should specify expand , if you want to get a VM instance View . Try the code below :
compute_client.virtual_machines.get(resource_group_name, virtual_machine_name,expand='instanceView').instance_view.statuses[1].display_status
Result:
I am working with a mobile game API and a Telegram Bot. It worked when I put in a fixed Clantag, but now I wanted to let the user write a tag and add it to the link. The app then should search for the clan and get the right stats. Everything is ok but I get this message now and cannot find my mistake. Would be happy if you could help!
def main():
last_update_id = None
message = ""
while True:
updates = get_updates(last_update_id)
if len(updates["result"]) > 0:
last_update_id = get_last_update_id(updates) + 1
message = get_last_update_Message(updates)
clan_stats(updates, message)
def get_last_update_Message(updates):
message = ""
for update in updates["result"]:
message = update["message"]
return message["text"]
def clan_stats(updates, ID):
#https://api.royaleapi.com/clan/1RLU78YU
Link = '"https://api.royaleapi.com/clan/' + ID + '"'
r=requests.get(Link, headers={"Accept":"application/json",
"authorization":"Bearer TOKENHERE"})
clan = r.json()
Full Traceback:
Traceback (most recent call last):
File "/home/Lee63225/clashroyaleclanbot.py", line 188, in <module>
main()
File "/home/Lee63225/clashroyaleclanbot.py", line 184, in main
clan_stats(updates, message)
File "/home/Lee63225/clashroyaleclanbot.py", line 80, in clan_stats
"authorization":"Bearer TOKENHERE"})
File "/usr/lib/python3.7/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3.7/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3.7/site-packages/requests/sessions.py", line 503, in request
prep.url, proxies, stream, verify, cert
File "/usr/lib/python3.7/site-packages/requests/sessions.py", line 676, in merge_environment_settings
env_proxies = get_environ_proxies(url, no_proxy=no_proxy)
File "/usr/lib/python3.7/site-packages/requests/utils.py", line 760, in get_environ_proxies
if should_bypass_proxies(url, no_proxy=no_proxy):
File "/usr/lib/python3.7/site-packages/requests/utils.py", line 716, in should_bypass_proxies
if is_ipv4_address(parsed.hostname):
File "/usr/lib/python3.7/site-packages/requests/utils.py", line 640, in is_ipv4_address
socket.inet_aton(string_ip)
TypeError: inet_aton() argument 1 must be str, not None
Thank you!
I think it should rather be
Link = 'https://api.royaleapi.com/clan/' + ID
There is some surrounding " in your attempt.
But now as I look, the function is called as clan_stats(update,message). That "message" should be a clantag, make sure it is (as now it comes from get_last_update_Message(), and looks very suspicious.
I have an issue with my bot:
I want to authorize user via phone_request. But it crashes. Although I get user phone. By phone_request I mean that I'm asking user for a phone number with this:
def get_keyboard():
contact_button = KeyboardButton('Start conversation',
request_contact=True)
reply_keyboard = [[contact_button]]
return reply_keyboard
I catch it with this:
dp.add_handler(MessageHandler(Filters.contact,
contact_callback,pass_user_data=True))
Than it goes there:
def contact_callback(bot, update):
contact = update.effective_message.contact
phone = contact.phone_number
print(contact)
print(phone)
update.message.reply_text('Thanks your data is accepted', get_authorized(), resize_keyboard=True)
get_authorized is simply this:
def get_authorized():
reply_keyboard = [['Pay', 'Why I'm in debt'], ['Remind Later']]
return reply_keyboard
What can go wrong here?
Traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/telegram/ext/dispatcher.py", line 279, in process_update
handler.handle_update(update, self)
File "/usr/local/lib/python3.5/dist-packages/telegram/ext/messagehandler.py", line 169, in handle_update
return self.callback(dispatcher.bot, update, **optional_args)
File "/home/ubuntu/Telegram_bot_OSDI/Telegram_Bot_OSDI_22.py", line 164, in contact_callback
update.message.reply_text('Спасибо! Ваши данные приняты', get_authorized(), resize_keyboard=True)
File "/usr/local/lib/python3.5/dist-packages/telegram/message.py", line 455, in reply_text
return self.bot.send_message(self.chat_id, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 65, in decorator
result = func(self, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 90, in decorator
result = self._request.post(url, data, timeout=kwargs.get('timeout'))
File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 309, in post
headers={'Content-Type': 'application/json'})
File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 223, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Unsupported parse_mode
So I'm trying to get Instagram photos that fit certain parameters and I'm getting the following stack:
Traceback (most recent call last):
File "instagram_find_shows.py", line 83, in <module>
if __name__ == "__main__": main()
File "instagram_find_shows.py", line 48, in main
get_instagram_posts(show_name, show_time, coordinates)
File "instagram_find_shows.py", line 73, in get_instagram_posts
str(coordinates[1]), min_time, max_time)
File "C:\Users\User Name\Anaconda3\lib\site-packages\instagram\bind.py", line 197, in _call
return method.execute()
File "C:\Users\User Name\Anaconda3\lib\site-packages\instagram\bind.py", line 189, in execute
content, next = self._do_api_request(url, method, body, headers)
File "C:\Users\User Name\Anaconda3\lib\site-packages\instagram\bind.py", line 163, in _do_api_request
raise InstagramAPIError(status_code, content_obj['meta']['error_type'], content_obj['meta']['error_message'])
instagram.bind.InstagramAPIError: (400) OAuthPermissionsException-This request requires scope=public_content, but this access token is not authorized with this scope. The user must re-authorize your application with scope=public_content to be granted this permissions.
The code is as follows:
def get_instagram_posts(name, time, coordinates):
max_time_dt = time + timedelta(hours=3)
min_time_dt = time - timedelta(hours=1)
max_time = str(calendar.timegm(max_time_dt.timetuple()))
min_time = str(calendar.timegm(min_time_dt.timetuple()))
dist_rad_str = str(insta_dist_radius_m)
count_str = str(insta_count)
api = InstagramAPI(access_token=insta_access_token,
client_secret=insta_client_secret)
r = api.media_search(name, count_str, str(coordinates[0]),
str(coordinates[1]), min_time, max_time)
photos = []
for media in r:
photos.append('<img src="%s"/>' % media.images['thumbnail'].url)
print(photos[0])
I can't figure out what to do... Literally I'm just trying to do a simple test, not trying to cripple their API. Is there any way to do this within Instagram's parameters? Thanks so much!
Fixed by going to the following URL in the browser:
https://www.instagram.com/oauth/authorize?client_id=[CLIENT_ID]&redirect_uri=[REDIRECT_URI]&response_type=code&scope=basic+public_content+follower_list+comments+relationships+likes
I have the following problem my database is not empty and has the record that I need. But when I query the db it says that there is no such object matching the given query. I query the db from within a websocket using django-channels and my database is postgreSQL.
I am aware that there are other questions about this and I looked into them but they are all about empty database or wrong url slug which is not my case and doesn't help me with anything
Here is the corresponding code:
#channel_session_user_from_http
def ws_receive(message):
username = message.user.username
print(username)
text = json.loads(message['text']).get('text')
# Use my algorithm here
score = score_argument.get_rating(text)
# find the room with our users
current_room = get_object_or_404(PairUsers, Q(username_a=username) | Q(username_b=username))
# current_room = PairUsers.objects.filter(Q(username_a=username) | Q(username_b=username)).first()
# check which user you got and send the message to the other
if current_room.username_b == username:
current_room.score_b = score
other_channel = Channel(current_room.reply_channel_a)
message.reply_channel.send({'text': text})
other_channel.send({'text': text})
else:
current_room.score_a = score
other_channel = Channel(current_room.reply_channel_b)
message.reply_channel.send({'text': text})
other_channel.send({'text': text})
Another thing that I noticed is that the print(username) does not print anything it just skips this line. I used message.user.username in different function that works so I am sure it should return the username
Traceback:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35\lib\site-packages\channels\worker.py", line 119, in run
consumer(message, **kwargs)
File "C:\Program Files (x86)\Python35\lib\site-packages\channels\sessions.py", line 180, in inner
result = func(message, *args, **kwargs)
File "C:\Program Files (x86)\Python35\lib\site-packages\channels\auth.py", line 73, in inner
return func(message, *args, **kwargs)
File "C:\Program Files (x86)\Python35\lib\site-packages\channels\sessions.py", line 64, in inner
return func(message, *args, **kwargs)
File "C:\Program Files (x86)\Python35\lib\site-packages\channels\auth.py", line 89, in inner
return func(message, *args, **kwargs)
File "C:\Users\nithe\Desktop\debateit\play\consumers.py", line 51, in ws_receive
current_room = get_object_or_404(PairUsers, Q(username_a=username) | Q(username_b=username))
File "C:\Program Files (x86)\Python35\lib\site-packages\django\shortcuts.py", line 93, in get_object_or_404
raise Http404('No %s matches the given query.' % queryset.model._meta.object_name)
django.http.response.Http404: No PairUsers matches the given query.
message.user.username appears to be None, your query will of course fail. This question is not a database problem (yet), it's channels related.
Try printing your message.user.__dict__, see if it matches the object you expect.