Skip to content

Commit

Permalink
Merge pull request #176 from tableau/development
Browse files Browse the repository at this point in the history
Merge version 2.2.0 to master
  • Loading branch information
mcoles authored Jan 6, 2021
2 parents 9ce26b9 + 2af5784 commit b799230
Show file tree
Hide file tree
Showing 15 changed files with 739 additions and 1,132 deletions.
678 changes: 139 additions & 539 deletions .idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
del .\dist\*.* /F /Q /S
python .\setup.py py2exe
rmdir .\dist /Q /S
pyinstaller vizalerts.py --onefile --clean --workpath .\dist\work

mkdir .\dist\vizalerts
pushd .\dist\vizalerts
Expand Down
4 changes: 2 additions & 2 deletions config/VizAlertsConfig.twb
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@
</desc>
</column>
<column caption='is_valid_schedule' datatype='boolean' name='[Calculation_5911012080139041]' role='dimension' type='nominal'>
<calculation class='tableau' formula='ISNULL(schedule_id) // this is a test alert, so that&apos;s okay&#13;&#10;&#13;&#10;// naming pattern to recognized VizAlerts schedules. feel free to edit. &#13;&#10;// Note that the schedules MUST be set to &quot;disabled&quot; in Tableau Server--this is required by the Custom SQL connection&#13;&#10;// ... which you should NOT change.&#13;&#10; OR CONTAINS(LOWER(schedule_name), LOWER([Parameters].[Parameter 9]))' scope-isolation='false' />
<calculation class='tableau' formula='[subscription_id] &lt; 0 // this is a test alert&#13;&#10;&#13;&#10;// naming pattern to recognized VizAlerts schedules. feel free to edit. &#13;&#10;// Note that the schedules MUST be set to &quot;disabled&quot; in Tableau Server--this is required by the Custom SQL connection&#13;&#10;// ... which you should NOT change.&#13;&#10; OR CONTAINS(LOWER(schedule_name), LOWER([Parameters].[Parameter 9]))' scope-isolation='false' />
<desc>
<formatted-text>
<run>Determines which Tableau Server subscription schedules are reserved for VizAlerts.&#10;&#10;Note that only </run>
Expand Down Expand Up @@ -2286,7 +2286,7 @@
</desc>
</column>
<column caption='is_valid_schedule' datatype='boolean' name='[Calculation_5911012080139041]' role='dimension' type='nominal'>
<calculation class='tableau' formula='ISNULL(schedule_id) // this is a test alert, so that&apos;s okay&#13;&#10;&#13;&#10;// naming pattern to recognized VizAlerts schedules. feel free to edit. &#13;&#10;// Note that the schedules MUST be set to &quot;disabled&quot; in Tableau Server--this is required by the Custom SQL connection&#13;&#10;// ... which you should NOT change.&#13;&#10; OR CONTAINS(LOWER(schedule_name), LOWER([Parameters].[Parameter 9]))' scope-isolation='false' />
<calculation class='tableau' formula='[subscription_id] &lt; 0 // this is a test alert, so that&apos;s okay&#13;&#10;&#13;&#10;// naming pattern to recognized VizAlerts schedules. feel free to edit. &#13;&#10;// Note that the schedules MUST be set to &quot;disabled&quot; in Tableau Server--this is required by the Custom SQL connection&#13;&#10;// ... which you should NOT change.&#13;&#10; OR CONTAINS(LOWER(schedule_name), LOWER([Parameters].[Parameter 9]))' scope-isolation='false' />
<desc>
<formatted-text>
<run>Determines which Tableau Server subscription schedules are reserved for VizAlerts.&#10;&#10;Note that only </run>
Expand Down
99 changes: 54 additions & 45 deletions docs/install_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tableau – VizAlerts Installation Guide
- [What is VizAlerts?](#what-is-vizalerts)
- [What does it do?](#what-does-it-do)
- [How does it work?](#how-does-it-work)
- [Upgrading from VizAlerts 2.1.0](#upgrading-from-vizalerts-2_1_0)
- [Upgrading from VizAlerts 2.1.1](#upgrading-from-vizalerts-2_1_1)
- [Installation Prerequisites](#installation-prerequisites)
- [Tableau Server](#tableau-server)
- [Tableau Desktop](#tableau-desktop)
Expand Down Expand Up @@ -131,50 +131,64 @@ The general flow of a single execution of VizAlerts goes like this:
instructed by the data itself.


Upgrading from VizAlerts 2.1.0<a id="upgrading-from-vizalerts-2_1_0"></a>
Upgrading from VizAlerts 2.1.1<a id="upgrading-from-vizalerts-2_1_1"></a>
=====================================

**NOTE** There are two important changes in this release:

- A fix to the VizAlertsConfig workbook for Tableau Server 2020.4.1

- Switch from Python 2 to Python 3

If you are running VizAlerts with the binary EXE file, and are not using Tableau Server 2020.4 or higher, there is little reason to upgrade to 2.2.0.
If you are running it as a Python script, it is recommended that you upgrade, as Python 2 has been discontinued.
If you are upgrading to Tableau Server 2020.4 or higher, you can choose to upgrade VizAlerts, or [edit your VizAlertsConfig workbook](https://github.com/tableau/VizAlerts/issues/175) instead (the simpler solution).

Upgrading to VizAlerts 2.2.0 when running as a Python script will require installing Python 3. My own experience was that it is best that you first remove Python 2 from your system by uninstalling it, and removing all references to it from your environment variables. Then, you need to [install Python 3](#install-python-required-modules). Please be aware that uninstalling Python 2 will begin a VizAlerts outage, so please TEST on a separate server first, and plan your deployment accordingly.

1. Backup your current VizAlerts directory to a separate location.

2. Download version 2.1.1 from <https://github.com/tableau/VizAlerts/releases>, and unzip to a *new* folder alongside your existing VizAlerts folder. You should have three folders at this point: The live, current installation, the backup of the current installation, and a new folder you unzipped v2.1.1 into.
2. Download version 2.2.0 from <https://github.com/tableau/VizAlerts/releases>, and unzip to a *new* folder alongside your existing VizAlerts folder. You should have three folders at this point: The live, current installation, the backup of the current installation, and a new folder you unzipped v2.2.0 into.

3. Merge VizAlertsConfig changes into new workbook
- There is a new version of \config\VizAlertsConfig.twb that contains a new Custom SQL query. It's easiest to simply drop this into your existing VizAlertsConfig workbook. To do so, here are the steps:
- There is a new version of \config\VizAlertsConfig.twb that contains an edit to the _is_valid_schedule_ calc. It's easiest to simply drop this minor change into your existing VizAlertsConfig workbook. To do so, here are the steps:
- Download your existing VizAlertsConfig workbook from Tableau Server and open it in Tableau Desktop
- Locate the *new* VizAlertsConfig workbook from the new VizAlerts folder, in the config subfolder, and open it in Tableau Desktop (you'll need to edit the connection to point to your Tableau Server postgreSQL database)
- Edit the connection in the new VizAlertsConfig workbook, then edit the one table in the connection pane. This will open the Custom SQL dialog.
- Copy the Custom SQL Query.
- Carefully update your *current* VizAlertsConfig workbook with the new Custom SQL query.
- Now re-publish the current VizAlertsConfig workbook to Tableau Server, **making sure** that you are embedding the password in the connection. This will not break v2.1.0 of VizAlerts.
- Edit the _is_valid_schedule_ calc in your VizAlertsConfig workbook so that the first line is **[subscription_id] < 0** rather than **ISNULL(schedule_id)**
- Now re-publish the current VizAlertsConfig workbook to Tableau Server, **making sure** that you are embedding the password in the connection. This will _not_ break v2.1.1 of VizAlerts.
<br><br>

4. Copy config files
4. Copy other config files
- Copy the \config\vizalerts.yaml file from your *current* VizAlerts folder *over* the same file in the *new* VizAlerts folder
- No changes were made to this file, so it will work just fine the way it is
- If you're using SSL to connect to Tableau Server, and have a certificate file you're storing in the VizAlerts folder, make sure it's copied to the new location
- If you've referenced any other files for passwords or anything else, make sure they're copied as well.
<br><br>

5. In Task Scheduler, disable the existing VizAlerts scheduled task.

6. <font color='red'>**VizAlerts outage begins**</font>

7. If you didn't already publish the updated version of VizAlertsConfig, publish it now, ensuring that you embed the password when you publish it!
7. Uninstall Python 2, and remove references to it from your environmental variables (again, this is optional, but should make things simpler--if you're a power user that knows Python inside and out, feel free to disregard)

8. Download and install Python 3 and [required modules](#install-python-required-modules)

9. If you didn't already publish the updated version of VizAlertsConfig, publish it now, ensuring that you embed the password when you publish it!

8. Rename folders
10. Rename folders
- Rename the existing VizAlerts folder with something like "-old" at the end of it
- Rename the new VizAlerts folder whatever the old one was called
<br><br>
9. Testing
11. Testing
- Open a command prompt, navigate to the VizAlerts folder, and execute VizAlerts one time. Ensure it runs properly, and review the logs if there are any errors.
- Test a single alert by adding a test\_alert comment to a viz, and then run it again in the command prompt, again ensuring that no errors are logged.
<br><br>
10. **Optional**: If you want to ensure that no alerts were skipped during the upgrade, copy the \ops\vizalerts.state file from the -old VizAlerts folder to the current one.
12. **Optional**: If you want to ensure that no alerts were skipped during the upgrade, copy the \ops\vizalerts.state file from the -old VizAlerts folder to the current one.

11. In Task Scheduler, enable the VizAlerts task
13. In Task Scheduler, enable the VizAlerts task

12. <font color='green'>**VizAlerts outage ends**</font>
14. <font color='green'>**VizAlerts outage ends**</font>

13. Remove the -old VizAlerts folder and any backups you made, whenever you feel comfortable
15. Remove the -old VizAlerts folder and any backups you made, whenever you feel comfortable


Installation Prerequisites <a id="installation-prerequisites"></a>
Expand Down Expand Up @@ -806,26 +820,16 @@ Here’s how to publish the workbook:
Optional: Install Python & Required Modules <a id="install-python-required-modules"></a>
-----------------------------------

If you wish to run VizAlerts as a Python script rather than a binary executable, you will need to follow these steps. Otherwise, you can skip this section. Note that the rest of the documentation assumes that you are running the binary executable, so whenever you see instructions to run vizalerts.exe, know that you'll need to use *python .\vizalerts.py* instead.
If you wish to run VizAlerts as a Python script rather than a binary executable, you will need to follow these steps. Otherwise, you can skip this section. Note that the rest of the documentation assumes that you are running the binary executable, so whenever you see instructions to run vizalerts.exe, know that you'll need to use *python .\vizalerts.py* instead. Additionally, please note that while these instructions are specific to Windows, VizAlerts can also be run on Linux.

1. On the Windows host you want to run VizAlerts from, download and install Python 2.7. This can be done in multiple ways, but we suggest this MSI installer: <https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi>
1. On the host you want to run VizAlerts from, download and install Python 3.7 or higher. This can be done in multiple ways, but we suggest the MSI installer from: <https://www.python.org/downloads/>. While it's possible to run two separate versions of Python, VizAlerts is only compatible with 3.7 and above, and it can be very confusing to sort out issues when both versions are installed on your machine.

2. Add ";C:\\Python27\\;C:\\Python27\\Scripts\\" to your Path environment variable (assuming you chose the installation defaults when installing Python)
2. It's recommended that you ensure that Python is added to your environmental PATH variable, when given that option in the installer.

3. Install the following Python modules:
3. Install the necessary Python modules by running the following commands:

1. [PyYAML](http://pyyaml.org/) (recommended: <http://pyyaml.org/download/pyyaml/PyYAML-3.11.win32-py2.7.exe> )

2. The final five modules,
[requests](http://docs.python-requests.org/en/latest/user/install/#install),
[requests\_ntlm](https://github.com/requests/requests-ntlm/),
[pypdf2](https://github.com/mstamy2/PyPDF2),
[twilio](https://pypi.python.org/pypi/twilio), and
[phonenumberslite](https://pypi.python.org/pypi/phonenumberslite),
are best installed by opening a *new* command prompt and running
the following commands:

pip install requests
pip install pyyaml
pip install requests
pip install requests\_ntlm
pip install pypdf2
pip install twilio
Expand All @@ -834,18 +838,18 @@ If you wish to run VizAlerts as a Python script rather than a binary executable,
* If your computer does not have access to the Internet, see
[Appendix A](#_Appendix_A).<br><br>

3. **Note**: Despite the requirement to install the last two
modules, deciding whether to *enable* the Twilio SMS integration
feature is up to you—either at the environment level, or at more
flexible sub-levels. Enabling the Twilio SMS integration
requires a Twilio account (free accounts are available).
Also, please also note that it’s possible to send SMS messages
*without* Twilio, as short email messages to subscribers who’s
mobile network providers have an email-to-SMS gateway available.
For example, <[email protected]> works in the USA. See the
SMS Actions section of the VizAlerts User Guide for
more details.
**Note**: Despite the requirement to install the last two
modules, deciding whether to *enable* the Twilio SMS integration
feature is up to you—either at the environment level, or at more
flexible sub-levels. Enabling the Twilio SMS integration
requires a Twilio account (free accounts are available).

Also, please also note that it’s possible to send SMS messages
*without* Twilio, as short email messages to subscribers who’s
mobile network providers have an email-to-SMS gateway available.
For example, <[email protected]> works in the USA. See the
SMS Actions section of the VizAlerts User Guide for
more details.

Configure VizAlerts <a id="configure-vizalerts"></a>
-------------------
Expand Down Expand Up @@ -1413,6 +1417,8 @@ you’ll be running VizAlerts from.
path they download to). These function as basically offline package
repositories:

*pip install --download c:\\mypythonpackages pyyaml*

*pip install --download c:\\mypythonpackages requests*

*pip install --download c:\\mypythonpackages requests\_ntlm*
Expand All @@ -1430,6 +1436,9 @@ you’ll be running VizAlerts from.
4. On your offline machine, install the package from the newly copied
folder:

*pip install --no-index --find-links file:c:\\mypythonpackages
pyyaml*

*pip install --no-index --find-links file:c:\\mypythonpackages
requests*

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

includes = []
includefiles = os.listdir('D:\\Python27\\Lib\\site-packages\\phonenumbers\\data')
includefiles = os.listdir('C:\\Python38\\Lib\\site-packages\\phonenumbers\\data')
for file in includefiles:
if file.endswith('.py'):
includes.append('phonenumbers.data.' + file.replace('.py', ''))
Expand Down
24 changes: 12 additions & 12 deletions tabUtil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
#
# global (to this module) variables
#
time_format = u"%Y-%m-%d"
log_time_format = u"%Y-%m-%d %H:%M:%S"
time_format = "%Y-%m-%d"
log_time_format = "%Y-%m-%d %H:%M:%S"

now = datetime.datetime.now().strftime(log_time_format)
today = datetime.datetime.now().strftime(time_format)
hostname = os.getenv("COMPUTERNAME")
cwd = os.getcwd()

# log formatter
formatter = u"%(threadName)s - %(asctime)s - [%(levelname)s] - %(funcName)s - %(message)s"
min_formatter = u"%(asctime)s - [%(levelname)s] - %(message)s"
extra_formatter = u"%(threadName)s - %(asctime)s - [%(thread)d] - %(levelname)s - %(module)s.%(funcName)s - %(message)s"
formatter = "%(threadName)s - %(asctime)s - [%(levelname)s] - %(funcName)s - %(message)s"
min_formatter = "%(asctime)s - [%(levelname)s] - %(message)s"
extra_formatter = "%(threadName)s - %(asctime)s - [%(thread)d] - %(levelname)s - %(module)s.%(funcName)s - %(message)s"

# file log rotation constants
max_size = 20*1024*1024 # in Bytes (5 MB)
Expand All @@ -42,8 +42,8 @@ def load_yaml_file(yaml_file):
# See http://stackoverflow.com/questions/2890146/how-to-force-pyyaml-to-load-strings-as-unicode-objects
def construct_yaml_str(self, node):
return self.construct_scalar(node)
Loader.add_constructor(u'tag:yaml.org,2002:str', construct_yaml_str)
SafeLoader.add_constructor(u'tag:yaml.org,2002:str', construct_yaml_str)
Loader.add_constructor('tag:yaml.org,2002:str', construct_yaml_str)
SafeLoader.add_constructor('tag:yaml.org,2002:str', construct_yaml_str)


# Logger
Expand All @@ -66,14 +66,14 @@ def Logger(logfile_name, log_level=logging.INFO, time_format=log_time_format, ex
# check the if any args have been passed in via kw
#
# -- logging levels --
if kw.has_key("console_level"):
if "console_level" in kw:
console_logging_level = kw["console_level"]
# -- formatters --
if kw.has_key("log_formatter"):
if "log_formatter" in kw:
log_formatter = kw["log_formatter"]
if kw.has_key("console_formatter"):
if "console_formatter" in kw:
console_formatter = kw["console_formatter"]
if kw.has_key("format"):
if "format" in kw:
log_formatter = kw["format"]
console_formatter = log_formatter
# set up the logging instance
Expand Down Expand Up @@ -130,7 +130,7 @@ def LoggerQuickSetup(log_file, log_level=logging.INFO, filename_time_format='%Y-
# Simple wrapper method to handle prompting the user. Return 'True' or 'False' depending on whether the input matches
# the 'acceptable' value provided in the second argument.
def promptUser(msg, accptResp):
resp = raw_input(msg)
resp = input(msg)
if resp == accptResp:
return True
else:
Expand Down
7 changes: 7 additions & 0 deletions version_history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
VERSION HISTORY
===============

Version 2.2.0
=================================
-Refactor for Python 3 (Issue #111)
-Fix SMS error handling (Issue #158)
-Fix for test alerts breaking in 2020.4 (Issue #175)
=================================

Version 2.1.1
=================================
-Documentation updates (Issue #124)
Expand Down
Loading

0 comments on commit b799230

Please sign in to comment.