Exemple #1
0
def run(args):
    ''' main script  after arguments '''
    from deployer import Deployer

    # This script expects that the following environment vars are set:
    #
    # AZURE_TENANT_ID: with your Azure Active Directory tenant id or domain
    # AZURE_CLIENT_ID: with your Azure Active Directory Application Client ID
    # AZURE_CLIENT_SECRET: with your Azure Active Directory Application Secret


    msg = "\nInitializing the Deployer class with subscription id: {}, resource group: {}" \
          "\nand public key located at: {}...\n\n"
    msg = msg.format(args.my_subscription_id, args.my_resource_group,
                     args.my_pub_ssh_key_path)
    logging.info(msg)

    # Initialize the deployer class
    deploy = Deployer(subscription_id=args.my_subscription_id,
                      location=args.location)
    ##

    logging.info("Beginning the deployment... \n\n")
    # Deploy the template
    args.dns_label_prefix = args.vmName.lower(
    )  ##re ^[a-z][a-z0-9-]{1,61}[a-z0-9]$

    deploy.deploy(vars(args))

    logging.warn(
        "Done deploying!!\n\nYou can connect via: `ssh {}@{}.australiaeast.cloudapp.azure.com`"
        .format(args.adminUserName, args.dns_label_prefix))
    logging.debug(str(deploy))
Exemple #2
0
def deploy(slug, testing_url, production_url, theme_url, production_server, production_dir):
    build_dir = os.path.join(SETTINGS.BUILD_DIR, slug)
    archive_dir = os.path.join(SETTINGS.ARCHIVE_DIR, slug)

    compiler = Compiler(build_dir, testing_url, production_url, theme_url)
    compiler.compile()

    archiver = Archiver(slug, build_dir, archive_dir)
    archive = archiver.archive()

    deployer = Deployer(production_server, SETTINGS.SSH_KEY, archive_dir, production_dir)
    deployer.deploy(archive)

    return True
def run_example(config):
    try:
        my_subscription_id = config[
            'subscriptionId']  # your Azure Subscription Id
        my_resource_group = 'azure-python-deployment-sample'  # the resource group for deployment
        my_pub_ssh_key_path = os.path.expanduser(
            '~/.ssh/id_rsa.pub')  # the path to your rsa public key file

        msg = "\nInitializing the Deployer class with subscription id: {}, resource group: {}" \
            "\nand public key located at: {}...\n\n"
        msg = msg.format(my_subscription_id, my_resource_group,
                         my_pub_ssh_key_path)
        print(msg)

        # Initialize the deployer class
        deployer = Deployer(config, my_resource_group, my_pub_ssh_key_path)

        print("Beginning the deployment... \n\n")
        # Deploy the template
        my_deployment = deployer.deploy()

        print("Done deploying!!")

    finally:
        print("Cleaning up the deployment... \n\n")
        #Destroy the resource group which contains the deployment
        deployer.destroy()
        print("Clean up the deployment sucessfully. \n")
Exemple #4
0
def main():
  config = get_config()
  name = config.name
  img_name = "deploy_data/" + name + ".tif"
  data = skimage.io.imread(img_name)

  print data.shape
 
  data = np.expand_dims(data, axis=3)
  data = (data / 255.).astype(np.float32)
  
  print data.shape

  with tf.Session() as sess:
    deployer = Deployer(sess, data, config)
    deployer.deploy()
Exemple #5
0
def main():
    parser = argparse.ArgumentParser(description='pyginate - static web site generator')
    parser.add_argument('action', help='Action to perform', choices=['build', 'deploy', 'process'])
    parser.add_argument('-d', '--dir', help='Web site base directory', default=os.getcwd())
    parser.add_argument('-c', '--config_file_name', help='Configuration file name', default='pyginator.json')
    parser.add_argument('-s', '--processing_script', help='Procesing script to apply', default='')
    parser.add_argument('-dr', '--dry_run', action='store_true', help='Do not apply any changes, just report')
    args = parser.parse_args()
    conf_file = os.path.join(args.dir, args.config_file_name)
    configuration = Configuration(args.dir, json.load(open(conf_file)))
    if args.action == 'build':
        builder = Builder(configuration)
        builder.build()
    elif args.action == 'deploy':
        deployer = Deployer(configuration)
        deployer.deploy()
    elif args.action == 'process':
        if args.dry_run:
            configuration.dry_run = True
        processor = Processor(configuration, args.processing_script)
        processor.process()
Exemple #6
0
async def handle(request: Command):
    namespace = request.namespace
    command = request.command
    event = request.event
    print(
        f"Received namespace: {namespace}, command: {command}, event: {event}")

    if not command:
        return {
            "message":
            f":red_circle: No command provided.  Try `.{namespace} help`"
        }

    cmd_parts = command.split()
    # slack sends links surrounded by angle brackets (<, >) if it recognizes a URL, so we need to extract the URL
    substring = SlackFormattedSubstring(cmd_parts[0])
    handler_url = substring.get_content_or_none() if substring.is_url_link(
    ) else substring.get_raw()

    if not validators.url(handler_url):
        return {
            "message":
            (f":red_circle: `{handler_url}` does not seem to be a valid URL; see: "
             +
             "https://validators.readthedocs.io/en/latest/index.html#module-validators.url"
             )
        }

    deployer = Deployer(handler_url)

    if len(cmd_parts) > 1:
        if cmd_parts[1] == "to":
            if len(cmd_parts) == 3:
                deployer.set_environment(cmd_parts[2])
            else:
                return {
                    "message":
                    f":red_circle: I don't understand that command; try: `.{namespace} help`"
                }
        else:
            return {
                "message":
                f":red_circle: I don't understand that command; try: `.{namespace} help`"
            }
    elif len(cmd_parts) > 3:
        return {
            "message":
            f":red_circle: I don't understand that command; try: `.{namespace} help`"
        }

    return {"message": deployer.deploy()}
def deploy():
    deployer = Deployer()
    print("\nDeploying contract...")
    (contract, tx_hash) = deployer.deploy(
        compiled_path,
        contract_name,
        {
            "from": sender_account,
            "value": 0,
            "nonce": 1642,
            "gas": gas,
            "gasPrice": gas_price
        },
    )
    print("\nDeployment transaction hash: ", tx_hash.hex(),
          "\nCrowdsale address: ", contract.address)
    write_to_address_log(contract)
    return contract
Exemple #8
0

def random_receiver():
    return eth.accounts[random.randint(0, len(eth.accounts) - 1)]


tx = {"from": owner, "value": 0, "gas": gas, "gasPrice": gas_price}


def tx_from(tx_sender):
    return {"from": tx_sender, "value": 0, "gas": gas, "gasPrice": gas_price}


(token, deployment_hash) = deployer.deploy(
    "./build/",
    "ReleasableToken",
    tx,
)

#EXAMPLE succeeds("Unhalt succeeds", haltable_contract.functions.unhalt().transact(tx))

succeeds("ReleasableToken construction shouldn't fail.", deployment_hash)

assert token.functions.released().call() == False, "Shouldn't start released"

fails(
    "Shouldn't allow transfers from a non transfer agent",
    token.functions.transfer(random_receiver(),
                             random_contribution()).transact(
                                 tx_from(non_transfer_agent)))
Exemple #9
0
def restore(slug, archive, production_server, production_dir):
    archive_dir = os.path.join(SETTINGS.ARCHIVE_DIR, slug)

    deployer = Deployer(production_server, SETTINGS.SSH_KEY, archive_dir, production_dir)
    deployer.deploy(archive)
    groupnames.append(item.name)
print(groupnames)
x = template["Deployed_Region"]
for item in x:
    my_location = str(item)
    deployement_status = str(x[item])
    my_resource_group = template["ResourceGroup"] + "_" + my_location
    print(my_location + " : " + deployement_status)
    print(my_resource_group)
    deployer = Deployer(my_subscription_id, my_resource_group, my_location,
                        my_pub_ssh_key_path)

    if my_resource_group in groupnames:
        if deployement_status == "False":

            msg = "\nInitializing the Deployer class with subscription id: {}, resource group: {}" \
                "\nand public key located at: {}...\n\n"
            msg = msg.format(my_subscription_id, my_resource_group,
                             my_pub_ssh_key_path)
            print(msg)
            deployer.destroy()
    if deployement_status == "True":
        msg = "\nInitializing the Deployer class with subscription id: {}, resource group: {}" \
                "\nand public key located at: {}...\n\n"
        msg = msg.format(my_subscription_id, my_resource_group,
                         my_pub_ssh_key_path)
        print(msg)
        deployer.deploy()

#"{'properties': <azure.mgmt.resource.resources.models.resource_group_properties.ResourceGroupProperties object at 0x7c5802963c50>, 'name': 'AZ300', 'id': '/subscriptions/2a5752bf-ed9d-456e-830e-e398e97d9c7b/resourceGroups/AZ300', 'location': 'uksouth', 'tags': {'Owner': 'Piers', 'Environemnt': 'Test'}}"
Exemple #11
0
sys.path.append("../deployment")
from deployer import Deployer
from web3_interface import Web3Interface
from tx_checker import fails, succeeds
from test_config import config_f
from generic_crowdsale_mock_checker import GenericCrowdsaleChecker

web3 = Web3Interface().w3
config = config_f()
web3.miner.start(1)
deployer = Deployer()
accounts = web3.eth.accounts
sender = accounts[0]
gas = 50000000
gas_price = 20000000000
tx = {"from": sender, "value": 0, "gas": gas, "gasPrice": gas_price}

(generic_crowdsale_mock_contract, tx_hash) = deployer.deploy(
    "./build/",
    "GenericCrowdsaleMock",
    tx,
)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 1
functions = generic_crowdsale_mock_contract.functions

generic_crowdsale_mock_interface = GenericCrowdsaleChecker(
    config,
    "GenericCrowdsaleMock",
    contract_addr=generic_crowdsale_mock_contract.address)
Exemple #12
0
from tx_checker import fails, succeeds
from test_config import config_f

web3 = Web3Interface().w3
web3.miner.start(1)
deployer = Deployer()
accounts = web3.eth.accounts
sender = accounts[0]
gas = 50000000
gas_price = 20000000000
tx = {"from": sender, "value": 0, "gas": gas, "gasPrice": gas_price}
config = config_f()
to_mint = 100000
address_zero = web3.toChecksumAddress("0x0000000000000000000000000000000000000000")

(mintable_token_contract, tx_hash) = deployer.deploy("./build/", "MintableTokenMock", tx, config['multisig_supply'], address_zero, True)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 0


(mintable_token_contract, tx_hash) = deployer.deploy("./build/", "MintableTokenMock", tx, 0, config['MW_address'], False)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 0


(mintable_token_contract, tx_hash) = deployer.deploy("./build/", "MintableTokenMock", tx, config['multisig_supply'], config['MW_address'], True)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 1
functions = mintable_token_contract.functions

Exemple #13
0
import sys

sys.path.append("../deployment")
from deployer import Deployer
from web3_interface import Web3Interface
from tx_checker import fails, succeeds

web3 = Web3Interface().w3
web3.miner.start(1)
owner = web3.eth.accounts[0]
new_owner = web3.eth.accounts[1]
tx = {'from': owner, 'gas': 100000000, 'gasPrice': 20000000000}
deployer = Deployer()
(haltable_contract, tx_hash) = deployer.deploy(
    "./build/",
    "Haltable",
    tx,
)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 1
functions = haltable_contract.functions


def halted():
    return functions.halted().call()


def get_owner():
    return functions.owner().call()

import sys
sys.path.append("../deployment")
from deployer import Deployer
from web3_interface import Web3Interface
from tx_checker import fails, succeeds

web3 = Web3Interface().w3
web3.miner.start(1)
deployer = Deployer()
accounts = web3.eth.accounts
sender = accounts[0]
gas = 50000000
gas_price = 20000000000
tx = {"from": sender, "value": 0, "gas": gas, "gasPrice": gas_price}

(standard_token_contract, tx_hash) = deployer.deploy("./build/", "StandardTokenMock", tx,)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 1
functions = standard_token_contract.functions
token_balances = {x : 0 for x in accounts}
allowed = {i : {x : 0 for x in accounts} for i in accounts}
total_supply = 0
value_transfer = 10000
value_mint = 100000

def get_total_supply():
  return functions.totalSupply().call()
def balance_of(address):
  return functions.balanceOf(address).call()
def allowance(account, spender):
  return functions.allowance(account, spender).call()
address_zero = "0x0000000000000000000000000000000000000000"
gas = 50000000
gas_price = 20000000000
tx0 = {"from": address_zero, "value": 0, "gas": gas, "gasPrice": gas_price}
txmaster = {"from": master, "value": 0, "gas": gas, "gasPrice": gas_price}
txmasterwogas = {"from": master, "value": 0}
txnewmaster = {
    "from": newmaster,
    "value": 0,
    "gas": gas,
    "gasPrice": gas_price
}
original_supply = 525 * (10**3) * (10**18)

(upgrade_agent_contract,
 tx_hash_agent) = deployer.deploy("./build/", "UpgradeAgentMock", txmaster,
                                  original_supply)
receipt_agent = web3.eth.waitForTransactionReceipt(tx_hash_agent)
assert receipt_agent.status == 1
print("Deployed UpgradeAgentMock")
(upgradeable_token_contract,
 tx_hash) = deployer.deploy("./build/", "UpgradeableTokenMock", txmaster,
                            original_supply)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 1
print("Deployed UpgradeableTokenMock")
functions = upgradeable_token_contract.functions


def upgrade_master():
    return functions.upgradeMaster().call()
# AZURE_SUBSCRIPTION_ID: your subscription id
# AZURE_RESOURCE_LOCATION: with your azure stack resource location
# this example assumes your ssh public key present here: ~/id_rsa.pub

my_subscription_id = os.environ.get(
    'AZURE_SUBSCRIPTION_ID')  # your Azure Subscription Id
my_resource_group = 'azure-python-deployment-sample'  # the resource group for deployment
my_pub_ssh_key_path = os.path.expanduser(
    '~/id_rsa.pub')  # the path to your rsa public key file

# Set Azure stack supported API profile as the default profile
KnownProfiles.default.use(KnownProfiles.v2018_03_01_hybrid)

msg = "\nInitializing the Deployer class with subscription id: {}, resource group: {}" \
    "\nand public key located at: {}...\n\n"
msg = msg.format(my_subscription_id, my_resource_group, my_pub_ssh_key_path)
print(msg)

# Initialize the deployer class
deployer = Deployer(my_subscription_id, my_resource_group, my_pub_ssh_key_path)

print("Beginning the deployment... \n\n")
# Deploy the template
my_deployment = deployer.deploy()

print(
    "Done deploying!!\n\nYou can connect via: `ssh azureSample@{}.local.cloudapp.azurestack.external`"
    .format(deployer.dns_label_prefix))

# Destroy the resource group which contains the deployment
# deployer.destroy()
Exemple #17
0
from tx_checker import fails, succeeds
from test_config import config_f

web3 = Web3Interface().w3
config = config_f()
web3.miner.start(1)
deployer = Deployer()
accounts = web3.eth.accounts
sender = accounts[0]
gas = 50000000
gas_price = 20000000000
tx = {"from": sender, "value": 0, "gas": gas, "gasPrice": gas_price}

(crowdsale_token_contract,
 tx_hash) = deployer.deploy("./build/", "CrowdsaleToken", tx,
                            config["multisig_supply"],
                            config["token_decimals"], config["MW_address"],
                            config["token_retriever_account"])
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 1
functions = crowdsale_token_contract.functions


def can_upgrade():
    return functions.canUpgrade().call()


def release_token_transfer(tx_args):
    return functions.releaseTokenTransfer().transact(tx_args)


assert functions.name().call() == "BurgerKoenig"
Exemple #18
0
from test_config import config_f
import time

web3 = Web3Interface().w3
web3.miner.start(1)
deployer = Deployer()
owner = web3.eth.accounts[0]
gas = 50000000
gas_price = 20000000000
tx = {"from": owner, "value": 0, "gas": gas, "gasPrice": gas_price}
config = config_f()
tokens_sold_example = 34 * 10**23

(token_tranche_pricing_contract, tx_hash) = deployer.deploy(
    "./build/",
    "TokenTranchePricingMock",
    tx,
)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 1
functions = token_tranche_pricing_contract.functions


def get_tranches_length():
    return functions.getTranchesLength().call()


assert get_tranches_length() == 0
succeeds(
    "Configuration of TokenTranchePricing succeeds.",
    functions.configurateTokenTranchePricingMock(
import time

web3 = Web3Interface().w3
web3.miner.start(1)
deployer = Deployer()
accounts = web3.eth.accounts
sender = accounts[0]
gas = 50000000
gas_price = 20000000000
tx = {"from": sender, "value": 0, "gas": gas, "gasPrice": gas_price}
agent_to_approve = accounts[2]
tokens_to_approve = 100000

(standard_token_mock_contract, tx_hash_standard_token) = deployer.deploy(
    "./build/",
    "StandardTokenMock",
    tx,
)

time.sleep(1.4)

(lost_and_found_token_contract, tx_hash) = deployer.deploy(
    "./build/",
    "LostAndFoundTokenMock",
    tx,
)
receipt = web3.eth.waitForTransactionReceipt(tx_hash)
assert receipt.status == 1
functions = lost_and_found_token_contract.functions

Exemple #20
0
def deploy(is_test):
    deployer = Deployer(is_test)
    deployer.deploy()
    pass
import os.path
from deployer import Deployer


# This script expects that the following environment vars are set:
#
# AZURE_TENANT_ID: with your Azure Active Directory tenant id or domain
# AZURE_CLIENT_ID: with your Azure Active Directory Application Client ID
# AZURE_CLIENT_SECRET: with your Azure Active Directory Application Secret

my_subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', '11111111-1111-1111-1111-111111111111')   # your Azure Subscription Id
my_resource_group = 'azure-python-deployment-sample'            # the resource group for deployment
my_pub_ssh_key_path = os.path.expanduser('~/.ssh/id_rsa.pub')   # the path to your rsa public key file

msg = "\nInitializing the Deployer class with subscription id: {}, resource group: {}" \
    "\nand public key located at: {}...\n\n"
msg = msg.format(my_subscription_id, my_resource_group, my_pub_ssh_key_path)
print(msg)

# Initialize the deployer class
deployer = Deployer(my_subscription_id, my_resource_group, my_pub_ssh_key_path)

print("Beginning the deployment... \n\n")
# Deploy the template
my_deployment = deployer.deploy()

print("Done deploying!!\n\nYou can connect via: `ssh azureSample@{}.westus.cloudapp.azure.com`".format(deployer.dns_label_prefix))

# Destroy the resource group which contains the deployment
# deployer.destroy()
Exemple #22
0
def build(config: dict, args: argparse.Namespace) -> None:
    model = args.model
    group = args.group
    pipeline = args.pipeline

    if group:
        models = config['model_groups'].get(group)
        if not models:
            print(f'Group {group} does not exist or empty')
            return
    elif model:
        models = [model]
    else:
        print('Please, specify group or model full name')
        return

    absent_models = set(models) - set(config['models'].keys())
    if len(absent_models) > 0:
        absent_models = ', '.join(absent_models)
        print(f'Unknown model full names: {absent_models}')
        return

    if pipeline and pipeline not in preset_pipelines.keys():
        print(f'Unknown pipeline name: {pipeline}')
        return
    elif pipeline:
        for model in models:
            config['models'][model]['pipeline'] = pipeline
    else:
        absent_pipeline_models = []
        for model in models:
            if config['models'][model].get(
                    'pipeline') not in preset_pipelines.keys():
                absent_pipeline_models.append(model)
        if absent_pipeline_models:
            absent_pipeline_models = ', '.join(absent_pipeline_models)
            print(
                f'Incorrect or absent pipeline names for: {absent_pipeline_models}'
            )
            return

    # Test Docker Hub authentication
    dockerhub_password = args.dockerhub_pass

    if not dockerhub_password:
        prompt_text = 'Docker Hub password was not entered, would you like for proceed without Docker Hub login?'
        if not prompt_confirmation(prompt_text):
            return
    else:
        try:
            client: DockerClient = DockerClient(
                base_url=config['docker_base_url'])
            client.login(config['dockerhub_registry'], dockerhub_password)
        except APIError as e:
            print(e)
            prompt_text = 'Docker Hub login error occurred, would you like for proceed without Docker Hub login?'
            if not prompt_confirmation(prompt_text):
                return

    config['dockerhub_password'] = dockerhub_password

    deployer = Deployer(config)
    deployer.deploy(models)
Exemple #23
0
 def deploy(self):
     deployer = Deployer(self.project)
     deployer.deploy()
     return self.project