From 66373f4c9145a6313d86e51eddfe041a4c8166df Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 12 Feb 2021 13:33:54 +0000 Subject: [PATCH 1/3] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 2cf9fbb..619320e 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,5 @@ dmypy.json website/__init__.py /twitter/bot/__init__.py /twitter/__init__.py +/bot/__init__.py +/cuckoo/__init__.py From 5b5406f915fcaf24908aa4d2ddbfb0e4c3884925 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 12 Feb 2021 13:35:03 +0000 Subject: [PATCH 2/3] Source email templates --- cuckoo/templates/LICENSE | 202 ++++ cuckoo/templates/NOTICE | 5 + cuckoo/templates/come_to_work.html | 211 ++++ cuckoo/templates/daily_tasks.html | 1583 ++++++++++++++++++++++++++++ cuckoo/templates/pickup.html | 236 +++++ 5 files changed, 2237 insertions(+) create mode 100755 cuckoo/templates/LICENSE create mode 100755 cuckoo/templates/NOTICE create mode 100755 cuckoo/templates/come_to_work.html create mode 100755 cuckoo/templates/daily_tasks.html create mode 100755 cuckoo/templates/pickup.html diff --git a/cuckoo/templates/LICENSE b/cuckoo/templates/LICENSE new file mode 100755 index 0000000..30a54c0 --- /dev/null +++ b/cuckoo/templates/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2013 Techdrop Labs Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/cuckoo/templates/NOTICE b/cuckoo/templates/NOTICE new file mode 100755 index 0000000..2309aaf --- /dev/null +++ b/cuckoo/templates/NOTICE @@ -0,0 +1,5 @@ +Apache sendwithus +Copyright 2013 The Apache Software Foundation + +This product includes software developed at Techdrop Labs Inc. +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/cuckoo/templates/come_to_work.html b/cuckoo/templates/come_to_work.html new file mode 100755 index 0000000..30da546 --- /dev/null +++ b/cuckoo/templates/come_to_work.html @@ -0,0 +1,211 @@ + + + + + +Work Reminder + + + + + + + + + + + + +
+ + +
+ + + + +
+

Reminder Email:

+

Hello {{ first_name }},

+

Remember that you're working today! Be sure to be in by 8am!

+

Have a question about this?

+

Please feel free to email support:

+
+
+ + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/cuckoo/templates/daily_tasks.html b/cuckoo/templates/daily_tasks.html new file mode 100755 index 0000000..39c2dd6 --- /dev/null +++ b/cuckoo/templates/daily_tasks.html @@ -0,0 +1,1583 @@ + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + +
+ + + + + +
+   +
+
+
+ +
+ + +
+ + + + +
+
+ + +
+ + + + + +
+

Daily Tasks!

+
+ Masthead Image +
+
+
+ + +
+ + + + + +
+   +
+
+ + + +
+ + + + +
+ Feature Image +
+
+ + + + +
+
Standard Tasks
+

Remember to do all of these today:
+ 1. Feed the dogs
+ 2. Feed the rabbits
+ 3. Feed the cats
+ 4. Feed the turtles
+ 5. Walk the dogs
+ 6. Empty cat litterboxes

+
+
+
+ + + +
+ + + + +
+ Feature Image +
+
+ + + + +
+
Periodic Tasks
+

Remember it's {{day_of_week}} so we also need to:
+ {{daily_tasks}} +

+
+
+
+ + +
+ + + + + +
+
+

+
Questions? Need more help?
+
Email the staff!
+
+
+
+
+
+ +
+ + +
+ + + + + +
+

© Copyright 2016 Sendwithus. All Rights Reserved.

+
+
+
+
+
+ + \ No newline at end of file diff --git a/cuckoo/templates/pickup.html b/cuckoo/templates/pickup.html new file mode 100755 index 0000000..991ac49 --- /dev/null +++ b/cuckoo/templates/pickup.html @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ (Optional) This text will appear in the inbox preview, but not the email body. +
+ + + +
+ + + + + + + + + + + + + + +
+ alt_text +
+ + + + +
+ Hello {{first_name}}, +
+
+ Your pets miss you! Please rememer to pick {{pet_name}} up by 7pm! +
+
+ The Woof Garden Team + + + + +

+ + + + + +
+ +     Map to our location     + +
+ +
+
+ + + + + + + +
+ View as a Web Page +

+ The Woof Garden
123 Fake Street, Philadelphia, PA, 19103 US
(123) 456-7890 +

+ unsubscribe +
+ + + +
+
+ + From 30ed9b47e34c2a4248240cc4b949f4b26f3acfeb Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 12 Feb 2021 13:35:49 +0000 Subject: [PATCH 3/3] Add tutorial code for generating emails --- cuckoo/README.md | 1 + cuckoo/commands_help.txt | 151 +++++++++++++++++++++++++++++++++++++ cuckoo/cuckoo.py | 159 +++++++++++++++++++++++++++++++++++++++ cuckoo/requirements.txt | 2 + cuckoo/setup.sh | 35 +++++++++ cuckoo/windows_setup.bat | 37 +++++++++ 6 files changed, 385 insertions(+) create mode 100755 cuckoo/README.md create mode 100755 cuckoo/commands_help.txt create mode 100755 cuckoo/cuckoo.py create mode 100755 cuckoo/requirements.txt create mode 100755 cuckoo/setup.sh create mode 100755 cuckoo/windows_setup.bat diff --git a/cuckoo/README.md b/cuckoo/README.md new file mode 100755 index 0000000..0b15b2e --- /dev/null +++ b/cuckoo/README.md @@ -0,0 +1 @@ +# Cuckoo diff --git a/cuckoo/commands_help.txt b/cuckoo/commands_help.txt new file mode 100755 index 0000000..8d18042 --- /dev/null +++ b/cuckoo/commands_help.txt @@ -0,0 +1,151 @@ +# This file should help you with the commands we'll be working through in this module. +# I'll also include documentation and notes where I think they might be useful. +# Commands will be unindented and uncommented (no # symbol at the beginning) + +# Part 1 - S3 Uploads +# When you open up your demos file you'll see a templates folder. +# Along with licence information are three modified html email templates. +# Each template is ready to use with Jinja2 but we'll need to move it to an S3 bucket. +# Keep in mind that bucket names are *globally* unique. Meaning you can't use mine! +# Replace gpc-email-templates with your bucket name. +# Also use the region you've been using throughout the course. +# The \ character is to escape line breaks and make the code more readable +# Here is the command to create a bucket with the AWS CLI: + +aws s3 mb s3://gpc-email-templates + +# Confirm the bucket was created + +aws s3 ls + +# Upload the templates to your s3 bucket +# Make sure you're in the /templates folder in your terminal first + +aws s3 cp ./templates s3://gpc-email-templates --recursive + +# Confirm the files were moved to s3 + +aws s3 ls gpc-email-templates + +# Notes: +# Keep in mind that Lambda cron() scheduling is done on UTC. +# To get a cron expression in your timezone you may need to change the values +# 7am EST - cron(0 12 ? * MON-FRI *) +# Noon EST - cron(0 17 ? * MON-FRI *) +# 5pm EST - cron(0 22 ? * MON-FRI *) +# Keep in mind time zone differences like Daylight Savings! + +# To add CloudWatch Events rules: +aws events put-rule \ +--name come_to_work \ +--schedule-expression 'cron(0 12 ? * MON-FRI *)' + +aws events put-rule \ +--name daily_tasks \ +--schedule-expression 'cron(0 17 ? * MON-FRI *)' + +aws events put-rule \ +--name pickup \ +--schedule-expression 'cron(0 22 ? * MON-FRI *)' + + +# With the events created make sure to modify your code skeleton +# Come back for these commands when you need to test locally + +# Testing the function from the command line: +# Make sure you're in the directory with the cuckoo.py file +# Open a Python shell + +python3 + +# In the python shell I'll put commands after >>> +# import the function + +>>> import cuckoo + +# Call the handler function and give it a sample event +# This event can either be the event ARN text or something else +# that contains text that contains some of the text that the +# function is looking for. +# The text should contain: +# 'come_to_work' or 'daily_tasks' or 'pickup' +# We'll also put them into the following format to match +# the way they will be passed to the function by the AWS event + +>>> cuckoo.handler({'resources':['some text containing the word pickup']},'context') + +>>> cuckoo.handler({'resources':['arn:aws:events:us-east-1:444510800003:rule/come_to_work']}, 'context') + +>>> cuckoo.handler({'resources':['a great daily_tasks test']},'context') + +# If successful you won't see any output so check your email for the results! + +# Setup and Deployment +# +# To take a look at creating our function package locally you can open +# the setup.sh file in a text editor. +# +# Deploying your function with the AWS CLI +# First make sure you've created your zip function package +# and you're in the same directory as that package.zip file +# Then list the roles on your account. +# We'll need to look for the role we created for this function earlier + +aws iam list-roles + +# We'll see something like this in the output: +# arn:aws:iam::444510800003:role/gpc_cuckoo_role +# Copy that role ARN because you'll need to replace the value +# after --role in the below command: + +aws lambda create-function \ +--function-name gpc_cuckoo \ +--runtime python3.7 \ +--role arn:aws:iam::444510800003:role/gpc_cuckoo_role \ +--handler cuckoo.handler \ +--zip-file fileb://./package.zip + +# Configure events to trigger the function +# +# +# List events + +aws events list-rules + +# We'll have the function trust events from each +# of these Cloudwatch Events + +aws lambda add-permission \ +--function-name gpc_cuckoo \ +--statement-id 1 \ +--action 'lambda:InvokeFunction' \ +--principal events.amazonaws.com \ +--source-arn arn:aws:events:us-east-1:444510800003:rule/pickup + +aws lambda add-permission \ +--function-name gpc_cuckoo \ +--statement-id 2 \ +--action 'lambda:InvokeFunction' \ +--principal events.amazonaws.com \ +--source-arn arn:aws:events:us-east-1:444510800003:rule/daily_tasks + +aws lambda add-permission \ +--function-name gpc_cuckoo \ +--statement-id 3 \ +--action 'lambda:InvokeFunction' \ +--principal events.amazonaws.com \ +--source-arn arn:aws:events:us-east-1:444510800003:rule/come_to_work + +# This will add the lambda function to each of the rules to be triggered +aws events put-targets \ +--rule daily_tasks \ +--targets '{"Id" : "1", "Arn": "arn:aws:lambda:us-east-1:444510800003:function:gpc_cuckoo"}' + +aws events put-targets \ +--rule come_to_work \ +--targets '{"Id" : "1", "Arn": "arn:aws:lambda:us-east-1:444510800003:function:gpc_cuckoo"}' + +aws events put-targets \ +--rule pickup \ +--targets '{"Id" : "1", "Arn": "arn:aws:lambda:us-east-1:444510800003:function:gpc_cuckoo"}' + diff --git a/cuckoo/cuckoo.py b/cuckoo/cuckoo.py new file mode 100755 index 0000000..7901a0b --- /dev/null +++ b/cuckoo/cuckoo.py @@ -0,0 +1,159 @@ +import datetime +import boto3 +from jinja2 import Template + +# Start of some things you need to change +# +# +# Recipient emails or domains in the AWS Email Sandbox must be verified +# You'll want to change this to the email you verify in SES +FROM_ADDRESS = 'globomanticspetcare@gmail.com' +REPLY_TO_ADDRESS = 'globomanticspetcare@gmail.com' + +CLIENTS = [ + { + # You'll need to verify this email + 'email': 'f_mcorey@yahoo.com', + 'first_name': 'Fernando', + 'last_name': 'Medina Corey', + 'pet_name': 'Riley' + }, +] + +EMPLOYEES = [ + { + # You'll need to verify this email + 'email': 'springfield.homer@yahoo.com', + 'first_name': 'Homer', + 'last_name': 'Simpson' + }, +] + +# Change to the bucket you create on your AWS account +TEMPLATE_S3_BUCKET = 'gpc-email-templates' + + +# +# +# End of things you need to change + +def get_template_from_s3(key): + """Loads and returns html template from Amazon S3""" + s3 = boto3.client('s3') + s3_file = s3.get_object( + Bucket=TEMPLATE_S3_BUCKET, + Key=key + ) + try: + template = Template(s3_file['Body'].read().decode('utf-8')) + except Exception as e: + print('Failed to load template') + raise e + return template + + +def render_come_to_work_template(employee_first_name): + template = get_template_from_s3('come_to_work.html') + html_email = template.render(first_name=employee_first_name) + plaintext_email = 'Hello {0}, \nPlease remember to be into work by 8am'.format(employee_first_name) + return html_email, plaintext_email + + +def render_daily_tasks_template(): + template = get_template_from_s3('daily_tasks.html') + tasks = { + 'Monday': '- Clean the dog areas\n', + 'Tuesday': '- Clean the cat areas\n', + 'Wednesday': '- Feed the aligator\n', + 'Thursday': '- Clean the dog areas\n', + 'Friday': '- Clean the cat areas\n', + 'Saturday': '- Relax! Play with the puppies! It\'s the weekend!', + 'Sunday': '- Relax! Play with the puppies! It\'s the weekend!' + } + # Gets an integer value from 0 to 6 for today (Monday - Sunday) + # Keep in mind this will run in GMT and you will need to adjust runtimes accordingly + days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] + today = days[datetime.date.today().weekday()] + html_email = template.render( + day_of_week=today, + daily_tasks=tasks[today] + ) + plaintext_email = ( + "Remember to do all of these today:\n" + "- Feed the dogs\n" + "- Feed the rabbits\n" + "- Feed the cats\n" + "- Feed the turtles\n" + "- Walk the dogs\n" + "- Empty cat litterboxes\n" + "{0}".format(tasks[today]) + ) + return html_email, plaintext_email + + +def render_pickup_template(client_first_name, client_pet_name): + template = get_template_from_s3('pickup.html') + html_email = template.render( + first_name=client_first_name, + pet_name=client_pet_name + ) + plaintext_email = ( + 'Hello {0}, \nPlease remember to ' + 'pickup {1} by 7pm!'.format( + client_first_name, + client_pet_name + ) + ) + return html_email, plaintext_email + + +def send_email(html_email, plaintext_email, subject, recipients): + try: + ses = boto3.client('ses') + response = ses.send_email( + Source=FROM_ADDRESS, + Destination={ + 'ToAddresses': [recipients], + 'CcAddresses': [], + 'BccAddresses': [] + }, + Message={ + 'Subject': { + 'Data': subject, + }, + 'Body': { + 'Text': { + 'Data': plaintext_email + }, + 'Html': { + 'Data': html_email + } + } + }, + ReplyToAddresses=[ + REPLY_TO_ADDRESS, + ] + ) + except Exception as e: + print('Failed to send message via SES') + print(e) + raise e + + +def handler(event, context): + event_trigger = event['resources'][0] + print('event triggered by ' + event_trigger) + if 'come_to_work' in event_trigger: + for employee in EMPLOYEES: + html_email, plaintext_email = render_come_to_work_template(employee['first_name']) + send_email(html_email, plaintext_email, 'Work Schedule Reminder', employee['email']) + elif 'daily_tasks' in event_trigger: + for employee in EMPLOYEES: + html_email, plaintext_email = render_daily_tasks_template() + send_email(html_email, plaintext_email, 'Daily Tasks Reminder', employee['email']) + elif 'pickup' in event_trigger: + for client in CLIENTS: + html_email, plaintext_email = render_pickup_template(client['first_name'], client['pet_name']) + send_email(html_email, plaintext_email, 'Pickup Reminder', client['email']) + else: + return 'No template for this trigger!' diff --git a/cuckoo/requirements.txt b/cuckoo/requirements.txt new file mode 100755 index 0000000..429e5af --- /dev/null +++ b/cuckoo/requirements.txt @@ -0,0 +1,2 @@ +Jinja2==2.11.1 +MarkupSafe==1.1.1 \ No newline at end of file diff --git a/cuckoo/setup.sh b/cuckoo/setup.sh new file mode 100755 index 0000000..1a7c8c6 --- /dev/null +++ b/cuckoo/setup.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Create and initialize a Python Virtual Environment +echo "Creating virtual environment - .venv" +python3 -m venv .venv + +echo "sourcing virtual environment - .venv" +source .venv/bin/activate + +# Create a directory to put things in +echo "Creating 'setup' directory" +mkdir setup + +# Move the relevant files into setup directory +echo "Moving function file(s) to setup dir" +cp cuckoo.py setup/ +cd ./setup + +# Install requirements +echo "pip installing requirements from requirements file in target directory" +pip install -r ../requirements.txt -t . + +# Prepares the deployment package +echo "Zipping package" +zip -r ../package.zip ./* + +# Remove the setup directory used +echo "Removing setup directory and virtual environment" +cd .. +rm -r ./setup +deactivate +rm -r .venv +# changing dirs back to dir from before +echo "Opening folder containg function package - 'package.zip'" +open . \ No newline at end of file diff --git a/cuckoo/windows_setup.bat b/cuckoo/windows_setup.bat new file mode 100755 index 0000000..1524adc --- /dev/null +++ b/cuckoo/windows_setup.bat @@ -0,0 +1,37 @@ +rem Create and initialize a Python Virtual Environment +echo "Creating the virtual environment - .venv" +python3 -m venv .venv + +echo "starting the virtual environment - .venv" +call .venv\Scripts\activate.bat + +rem Create a directory to put things in +echo "Creating 'setup' directory" +mkdir setup + +rem Move the relevant files into setup directory +echo "Moving function file(s) to setup dir" +xcopy cuckoo.py setup\ /Q /R /Y +cd .\setup + +rem Install requirements +echo "pip installing requirements from requirements file in target directory" +pip install -r ..\requirements.txt -t . + +rem Prepares the deployment package +echo "Setting up your 7zip PATH - This assumes the installation location of 7zip is in C:\Program Files\7-Zip\" +set PATH=%PATH%;C:\Program Files\7-Zip\ + +echo "Zipping package" +7z a -r ..\package.zip .\* + +rem Remove the setup directory used +echo "Removing setup directory and virtual environment" +cd .. +rd /Q /S .\setup +call .venv\Scripts\deactivate.bat +rd /Q /S .\.venv + +rem changing dirs back to dir from before +echo "Opening folder containg function package - 'package.zip'" +explorer . \ No newline at end of file