text
stringlengths 608
8.17k
|
---|
from flask import Flask, request, jsonify
from flask_jsonrpc import JSONRPC
# import json_to_db
import psycopg2
import sys
from obs import *
import config
app = Flask(__name__)
app.config.from_object(config.DevelopmentMaxConfig)
jsonrpc = JSONRPC(app,'/api')
sys.path.insert(0,app.config['SQL_PATH'])
from sql_methods import *
sys.path.insert(0,app.config['SCRIPTS_PATH'])
from file_utils import insert_history_to_file
@app.route('/')
def index():
return "Template to recieve data"
@app.route('/api/get_history', methods=['GET', 'POST'])
def get_history():
content = request.get_json(force=True)
insert_history_to_file(content, HISTORY_PATH)
return jsonify(content)
@app.route('/api/get_content', methods=['GET', 'POST'])
def get_content():
content = ("""{}""".format(request.get_json(force=True))).replace('\'','\"')
if content != "[]" and content:
if content[0] != '[':
content = '[' + content + ']'
content += '\n\n'
# print(content)
client.put(content)
return jsonify(content)
if __name__ == '__main__':
client = Client("127.0.0.1", 8181, app.config['DB'], app.config['USER'], app.config['PASSWORD'], app.config['HOST'], app.config['PORT'])
app.run(host='127.0.0.1', port= 5000)
# json_insert.to_csv('/Users/MaximZubkov/Desktop/Programming/Python/Python_Project/analysis/son.csv')
client.close() |
import datetime
import unittest
import unittest.mock as mock
from betdaq.apiclient import APIClient
from betdaq.endpoints.account import Account
class AccountTest(unittest.TestCase):
def setUp(self):
client = APIClient('username', 'password')
self.account = Account(client)
@mock.patch('betdaq.endpoints.account.Account.process_response')
@mock.patch('betdaq.endpoints.account.Account.request', return_value=mock.Mock())
def test_get_account_balances(self, mock_request, mock_process_response):
self.account.get_account_balances()
mock_request.assert_called_once_with('GetAccountBalances', {}, secure=True)
assert mock_process_response.call_count == 1
@mock.patch('betdaq.endpoints.account.Account.process_response')
@mock.patch('betdaq.endpoints.account.Account.request', return_value=mock.Mock())
def test_get_account_transactions(self, mock_request, mock_process_response):
self.account.get_account_transactions(StartTime=datetime.datetime(2017, 1, 1).timestamp(),
EndTime=datetime.datetime(2017, 1, 10).timestamp())
mock_request.assert_called_once_with(
'ListAccountPostings', {'StartTime': 1483228800.0, 'EndTime': 1484006400.0}, secure=True
)
assert mock_process_response.call_count == 1
@mock.patch('betdaq.endpoints.account.Account.process_response')
@mock.patch('betdaq.endpoints.account.Account.request', return_value=mock.Mock())
def test_get_account_transactions_by_id(self, mock_request, mock_process_response):
self.account.get_account_transactions_by_id(TransactionId=1)
mock_request.assert_called_once_with('ListAccountPostingsById', {'TransactionId': 1}, secure=True)
assert mock_process_response.call_count == 1
@mock.patch('betdaq.endpoints.account.Account.process_response')
@mock.patch('betdaq.endpoints.account.Account.request', return_value=mock.Mock())
def test_change_account_password(self, mock_request, mock_process_response):
self.account.change_account_password(Password='new_password')
mock_request.assert_called_once_with('ChangePassword', {'Password': 'new_password'}, secure=True)
assert mock_process_response.call_count == 1
|
"""
Credentials used when making CLIs.
"""
from pathlib import Path
from dcos_e2e.cluster import Cluster
DEFAULT_SUPERUSER_USERNAME = 'bootstrapuser'
DEFAULT_SUPERUSER_PASSWORD = 'deleteme'
def add_authorized_key(cluster: Cluster, public_key_path: Path) -> None:
"""
Add an authorized key to all nodes in the given cluster.
"""
nodes = {
*cluster.masters,
*cluster.agents,
*cluster.public_agents,
}
for node in nodes:
node.run(
args=['echo', '', '>>', '/root/.ssh/authorized_keys'],
shell=True,
)
node.run(
args=[
'echo',
public_key_path.read_text(),
'>>',
'/root/.ssh/authorized_keys',
],
shell=True,
)
|
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'txtUsername' => 'required',
'txtPassword' => 'required'
];
}
public function messages() {
return [
'txtUsername.required' => 'Bạn phải nhập vào username',
'txtPassword.required' => 'Bạn chưa nhập vào password'
];
}
}
|
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, SparkPost and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => env('SES_REGION', 'us-east-1'),
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
],
'google' => [
'client_id' => '488886135548-v6t87hsi6ohi2i3qkcrab1pk41gk83bi.apps.googleusercontent.com',
'client_secret' => 'qua3H8VlBuvExmhX2b7wKgYO',
'redirect' => 'http://www.gunny.site/callback',
],
]; |
<?php
return [
'name' => 'Name',
'user' => 'User',
'email' => 'E-Mail Address',
'password' => 'Password',
'confirmPassword' => 'Confirm Password',
'confirmEmail' => 'Please confirm your email!',
'emailConfirmed' => 'You confirmed your email, please log in!',
'profile' => 'Profile',
'makeAdmin' => 'Make User Admin',
'loseAdmin' => 'Take Away Admin Privileges',
'uploadPicture' => 'Upload Picture',
'editProfile' => 'Edit Profile',
'registerDate' => 'Joined at',
'height' => 'Height',
'weight' => 'Weight',
'benchPress' => 'Bench Press',
'squat' => 'Squat',
'deadlift' => 'Deadlift',
'ohp' => 'Overhead Press',
'image' => 'Image',
'cardHolder' => 'Card Holder Name',
'cardNumber' => 'Card Number',
'expMonth' => 'Expiration Month',
'expYear' => 'Expiration Year',
'amount' => 'Amount',
'thanksForDonation' => 'Thank you for your donation!',
'bmr' => 'BMR',
];
|
require 'rails_helper'
require 'byebug'
RSpec.describe UsersController, :type => :controller do
let(:user) { User.create!({ username: "jill_bruce", password: "password" }) }
describe "GET #show" do
it "renders the show template" do
get :show, id: user.id
expect(response).to render_template(:show)
end
end
describe "GET #index" do
it "renders the index template" do
get :index
expect(response).to render_template("index")
end
end
describe "POST #create" do
context "with invalid params" do
it "validates the presence of the user's username and password" do
post :create, user: { username: "jill_bruce", password: "" }
expect(response).to render_template("new")
expect(flash[:errors]).to be_present
end
it "validates that the password is at least 6 characters long" do
post :create, user: { username: "jill_bruce", password: "short" }
expect(response).to render_template("new")
expect(flash[:errors]).to be_present
end
end
context "with valid params" do
it "redirects user to user show on success" do
post :create, user: { username: "jill_bruce", password: "password" }
expect(response).to redirect_to(user_url(User.last))
end
end
end
end
|
class Akamai < Formula
desc "CLI toolkit for working with Akamai's APIs"
homepage "https://github.com/akamai/cli"
url "https://github.com/akamai/cli/archive/1.1.5.tar.gz"
sha256 "759c3c3bc59c2623fc8a5f91907f55d870f77aef1839f2ecc703db5c469b852a"
bottle do
cellar :any_skip_relocation
sha256 "a986f3bfc261227cd44447d5ff9cdfb461c50c002118d36caed068f5859432e1" => :catalina
sha256 "ce3ea6b8dba89d48bfec3be3bbf5701e7b1dcdde7a2f76a97dd668752b1e95fb" => :mojave
sha256 "2b6d07c4926858e1be33bef070a925a6746f396fa27566aaa313d5a2673cb25f" => :high_sierra
end
depends_on "dep" => :build
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
ENV["GLIDE_HOME"] = HOMEBREW_CACHE/"glide_home/#{name}"
srcpath = buildpath/"src/github.com/akamai/cli"
srcpath.install buildpath.children
cd srcpath do
system "dep", "ensure", "-vendor-only"
system "go", "build", "-tags", "noautoupgrade nofirstrun", "-o", bin/"akamai"
prefix.install_metafiles
end
end
test do
assert_match "Purge", shell_output("#{bin}/akamai install --force purge")
end
end
|
Subsets and Splits