Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def account_create():
accounts = Account.objects.all()
if len(accounts) > 0:
account = accounts[0]
else:
project.initialize(_client=UI_CLIENT, _service=UI_SERVICE, _user=UI_USER)
credentials = get_credentials('user')
account = Account.objects.get_or_create_user(credentials, 'password')
return account
def test_dictionary_credentials_user(self):
with open(self.user_file, 'r') as json_file:
project.initialize(_user=json.load(json_file))
service = get_service('oauth2', 'v2', 'user')
response = service.userinfo().get().execute()
self.assertIn('email', response)
self.helper_refresh()
def test_remote_credentials_user(self):
project.initialize(_user=self.user_file)
credentials = get_credentials('user')
account = Account.objects.get_or_create_user(credentials, 'password')
clear_credentials_cache()
project.initialize(_user=account.get_credentials_path())
self.assertEqual(project.recipe['setup']['auth']['user'], account.get_credentials_path())
service = get_service('oauth2', 'v2', 'user')
response = service.userinfo().get().execute()
self.assertIn('email', response)
self.helper_refresh()
# loop through accounts
for account in Account.objects.all():
print('CONVERTING', account.email)
try:
# load legacy credentials
credentials = legacy_credentails_get(legacy_credentials_path(account.identifier))
# convert to new format
new_credentials = CredentialsUserWrapper(credentials)
# save new credentials
account.set_credentials(new_credentials)
if kwargs['test']:
project.initialize(_user=account.get_credentials_path())
profile = get_profile()
print(profile)
exit()
except Exception as e:
print(str(e))
"partialSuccess": False,
"dryRun": False
}
if text is not None:
body['entries'][0]["textPayload"] = text
elif payload is not None:
body['entries'][0]["jsonPayload"] = payload
else:
# Removing tasks from job REMOVES ALL POTENTIAL CREDENTIALS IN CODE
job_buffer = json.loads(json.dumps(job, indent=2, sort_keys=True, default=str))
if 'tasks' in job_buffer['recipe']: del job_buffer['recipe']['tasks']
if 'auth' in job_buffer['recipe']['setup']: del job_buffer['recipe']['setup']['auth']
body['entries'][0]["jsonPayload"] = job_buffer
project.initialize(_service=UI_SERVICE, _project=UI_PROJECT)
try: API_StackDriver("service").entries().write(body=body).execute()
except: print('LOG EVENT ERROR')
execution_status
execution_timestamp
execution_stdout
execution_stderr
}
```
Args:
- event ( string ): One of the following: JOB_STARTED, JOB_COMPLETED, JOB_FAILED, JOB_TIMEDOUT
- job_id ( string ): The universal identifier of a job, used as key for record.
- execution_id ( string ): The id of the specific run of the job.
- stdout ( string ): Mesaging output form the task. Present depending on task.
- stderr ( string ): Error output form the task. Present if job failed.
"""
project.initialize(_service=UI_SERVICE, _project=UI_PROJECT)
datastore_write(
"service",
UI_PROJECT,
UI_LOG_NAMESPACE,
UI_LOG_KIND,
job_id,
{
'execution_id':execution_id,
'execution_status':event,
'execution_timestamp':datetime.utcnow(),
'execution_stdout':stdout,
'execution_stderr':stderr
}
)
client = bigquery.Client.from_service_account_json(UI_SERVICE)
def storage_list(account):
path = '%s:' % account.get_bucket(full_path=False)
project.initialize(_project=settings.CLOUD_PROJECT, _service=settings.CLOUD_SERVICE)
try:
for filename_storage in object_list('service', path, files_only=True):
yield Storage(filename_storage)
except:
pass # if no bucket then skip ( maybe not set up yet )
@permission_admin()
def storage(request):
bucket = request.user.get_bucket(full_path=False)
# create and permission bucket ( will do nothing if it exists )
project.initialize(_project=settings.CLOUD_PROJECT, _service=settings.CLOUD_SERVICE)
bucket_create('service', settings.CLOUD_PROJECT, bucket)
bucket_access('service', settings.CLOUD_PROJECT, bucket, 'OWNER', emails=[request.user.email])
return HttpResponseRedirect(request.user.get_bucket())
def storage_list(account):
path = '%s:' % account.get_bucket(full_path=False)
project.initialize(_project=settings.RECIPE_PROJECT, _service=settings.RECIPE_SERVICE)
try:
for filename_storage in object_list('service', path, files_only=True):
yield Storage(account, filename_storage)
except:
pass # if no bucket then skip ( maybe not set up yet )