key using Key.get_or_insert in google app
Hi everyone I'm beginner CTF player and I have same lake with python modules and I face following problem
i dump the file container the flag but it use python to generate it as a hash using this key
can same one help me to understand this code
key = Key.get_or_insert("key", namespace="default").secret.encode("utf-8")
secret = ndb.StringProperty()
logic has not changed, but so the code is easier to comment on
key = Key.get_or_insert('key', namespace='default') # if object exists retrieve it, otherwise create and retrieve it secret = key.secret # get value of secret field secret.encode('utf-8') # return an encoded version of the string as a bytes object.
See also questions close to this topic
Hey Wassup Lads
gevent flask in python
I have a code..and a domain name, I like to use this code to display in my domain name
from flask import Flask import gevent.wsgi app=Flask(__name__) @app.route('/') def index(): return "hello world" app_server = gevent.wsgi.WSGIServer(('x.y.z.a'), app) app_server.serve_forever()
It shows error:
Traceback (most recent call last): File "p.py", line 10, in <module> app_server = gevent.wsgi.WSGIServer(('126.96.36.199'), app) File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 605, in __init__ StreamServer.__init__(self, listener, backlog=backlog, spawn=spawn, **ssl_args) File "/usr/lib/python2.7/dist-packages/gevent/server.py", line 48, in __init__ BaseServer.__init__(self, listener, handle=handle, spawn=spawn) File "/usr/lib/python2.7/dist-packages/gevent/baseserver.py", line 61, in __init__ self.set_listener(listener) File "/usr/lib/python2.7/dist-packages/gevent/server.py", line 70, in set_listener BaseServer.set_listener(self, listener) File "/usr/lib/python2.7/dist-packages/gevent/baseserver.py", line 80, in set_listener self.family, self.address = parse_address(listener) File "/usr/lib/python2.7/dist-packages/gevent/baseserver.py", line 323, in parse_address raise ValueError('Failed to parse address %r: %s' % (address, sys.exc_info())) ValueError: Failed to parse address '188.8.131.52': invalid literal for int() with base 10: '184.108.40.206'
What to do.. Thanks for helping
How to place a name and set string xticks to GLAxisItem in PYQTgraph
I am trying to name the axes in PYQTgraph and also place some string xticks, however I do not know how to proceed. I hope there is some easier solution than creating my "own" GLAxisItem with new properties (methods) that can be called afterwards.
Here is my code:
from pyqtgraph.Qt import QtCore, QtGui import pyqtgraph.opengl as gl import numpy as np app = QtGui.QApplication() w = gl.GLViewWidget() w.opts['distance'] = 100 w.showMaximized() w.setWindowTitle('pyqtgraph example: GLViewWidget') x = ['a', 'b', 'c', 'd', 'e', 'f'] xdict = dict(enumerate(x)) ax = gl.GLAxisItem() ax.setSize(20,20,20) w.addItem(ax) pos = np.mgrid[0:10, 0:10, 0:1].reshape(3,10,10).transpose(1,2,0) # fixed widths, random heights size = np.empty((10,10,3)) size[...,0:2] = 0.4 size[...,2] = np.random.normal(size=(10,10)) bg = gl.GLBarGraphItem(pos, size) w.addItem(bg) ## Start Qt event loop unless running in interactive mode. if __name__ == '__main__': import sys if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): QtGui.QApplication.instance().exec_()
I will be grateful for any tip/suggestion.
Why this While True is only executed once?
I have a scenario like this:
def getData(): summaries = urlopen("http://xxyyzzz/").read().decode("utf-8") summaries = json.loads(summaries) return(summaries) def analis(): while True: summaries = getData() time.sleep(15)
I can't see a valid reason the portion of code inside my while should be run only once, where I'm getting wrong?
How to use a for loop to calculate mean of list of numbers python?
Trying to use a for loop to calculate the mean of a list as I want to practice.
This code is returning 4, 5, and 1 with the test cases. Can someone tell me what I'm doing wrong please?
def list_mean(p): total = 0 i = 0 if i < len(p): for t in p: total = total + p[i] i += 1 return i mean = i / len(p) return mean print list_mean([1,2,3,4]) >>> 2.5 print list_mean([1,3,4,5,2]) >>> 3.0 print list_mean() >>> 2.0
Print statements python degrading performance
How much python print statements impact the code performance?
I have 2.8M records to process, when i ran it with prints (log like --> Execution Success for "ID") on screen it was running too slow. when i piped '>' the script and ran it was showing performance boost.
my questions are -
if print on screen impacts the code performance?
let's suppose, one case is, i have logged-in to the screen where i am running the program and monitoring all the prints and other case i am logged off of the server but it would be still printing to terminal. will there be any performance difference in these two cases?
why i am seeing a performance increase when i piped ">" the prints into a file?
What is happening in the background?
Connect Biometric Device over tcp/ip to google IOT cloud
I have a biometric device which can connect to internet over tcp/ip. How can i add this device to google iot cloud.
What i need to do on device side?
Disable TLS/SSL check in Google App Engine - Java
My app is getting this error when accessing a HTTPS resource (using appengine-java-sdk-1.9.63):
javax.net.ssl.SSLHandshakeException: Could not verify SSL certificate for URL: https://some.where/ at com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:175) at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:45) at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:543) at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:422) at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getResponseCode(URLFetchServiceStreamHandler.java:275) at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:656) at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:629) at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:261) at org.jsoup.helper.HttpConnection.get(HttpConnection.java:250)
What can be done so GAE would not check of SSL since in my current purpose for the app, it does not care if it connects via HTTP or HTTPS, so in my case I just want to disable SSL check.
I am running the application from Windows (Linux does not throw the error above)
Already I have modifiied the dev_appserver.cmd like this:
java -Ddeployment.security.TLSv1.1=false -Ddeployment.security.TLSv1.2=false -cp "%~dp0\..\lib\appengine-tools-api.jar" ^ com.google.appengine.tools.KickStart ^ com.google.appengine.tools.development.DevAppServerMain %*
Also in the application itself this is set:
FetchOptions fetchOptions = FetchOptions.Builder.doNotValidateCertificate(); HTTPRequest request = new HTTPRequest(getUrl, HTTPMethod.GET, fetchOptions)
What could be wrong with Windows that it throws the error whereas in Linux there is no problem?
trying to upload photo using html python and google app engine
Can someone give a basic idea on how to approach the problem. It's not working on localhost and blobstore is also not working. Is there any other method or can someone show me the correct approach?