Commit 0ca92401 by O'Reilly Media, Inc.

Initial commit

File added
## Example files for the title:
# Threat Intelligence in Practice, by Allan Liska
[![Threat Intelligence in Practice, by Allan Liska](](
The following applies to example files from material published by O’Reilly Media, Inc. Content from other publishers may include different rules of usage. Please refer to any additional usage rights explained in the actual example files or refer to the publisher’s website.
O'Reilly books are here to help you get your job done. In general, you may use the code in O'Reilly books in your programs and documentation. You do not need to contact us for permission unless you're reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from our books does not require permission. Answering a question by citing our books and quoting example code does not require permission. On the other hand, selling or distributing a CD-ROM of examples from O'Reilly books does require permission. Incorporating a significant amount of example code from our books into your product's documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN.
If you think your use of code examples falls outside fair use or the permission given here, feel free to contact us at <>.
Please note that the examples are not production code and have not been carefully testing. They are provided "as-is" and come with no warranty of any kind.
import os
import sys
# Declare variables
isbn13 = sys.argv[1]
slug = sys.argv[2]
practiceArea = sys.argv[3]
bookId = sys.argv[4]
initialPdf = isbn13 + '.pdf'
initialEpub = isbn13 + '.epub'
initialMobi = isbn13 + '.mobi'
finalPdf = slug + '.pdf'
finalEpub = slug + '.epub'
finalMobi = slug + '.mobi'
csp = slug + '.csp'
localPath = '/Users/pkennedy/Documents/code/csp/'
fullCspPath = localPath + csp
filesForUpload = finalPdf + " " + finalEpub + " " + finalMobi
validPracticeAreas = [
legacyPracticeAreaMapping = {
if practiceArea in validPracticeAreas:
# Rename files for upload
os.rename(initialPdf, finalPdf)
os.rename(initialEpub, finalEpub)
os.rename(initialMobi, finalMobi)
fileRemoteLocation = "" + practiceArea + "/free/files"
cspRemoteLocation = "" + practiceArea + "/free"
# Copy the files securely to the server
os.system("scp " + filesForUpload + " " + fileRemoteLocation)
print("Upload Finished.")
# Create a new csp page with the same name as slug
# Check if practice area needs to be replaced with updated value.
if practiceArea in legacyPracticeAreaMapping:
practiceArea = legacyPracticeAreaMapping[practiceArea]
f = open(fullCspPath, "w")
f.write("<csif cond=\"{{}}\" eq=\"true\">\n"
"<csinclude record=\"b/{}\" template=\"freedownload-thanks-norm.view\" pa=\"{}\" shortlink=\"{}\"/>\n"
"<csinclude record=\"b/{}\" template=\"freedownload-norm.view\" pa=\"{}\" newsletter=\"yes\" />\n</csif>"
.format(bookId, practiceArea, slug, bookId, practiceArea))
print("CSP page created...")
print("Copying CSP page to remote server...")
os.system("chmod 664 " + fullCspPath)
os.system("scp " + fullCspPath + " " + cspRemoteLocation)
print("Please specify a valid Practice Area.")

6.29 KB

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment