diff --git a/.vs/KqlMagic/v15/.suo b/.vs/KqlMagic/v15/.suo index a39e2d9..f71c4d0 100644 Binary files a/.vs/KqlMagic/v15/.suo and b/.vs/KqlMagic/v15/.suo differ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..426e33b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at python@microsoft.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0b45575 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,9 @@ +# Contributing to KqlMagic + +If you would like to become an active contributor to this project please +follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://azure.github.io/guidelines/). + +## Code of Conduct +This project's code of conduct can be found in the +[CODE_OF_CONDUCT.md file](https://github.com/Microsoft/jupyter-Kqlmagic/blob/master/CODE_OF_CONDUCT.md) +(v1.4.0 of the http://contributor-covenant.org/ CoC). \ No newline at end of file diff --git a/KqlMagic.pyproj b/KqlMagic.pyproj index a16c25f..43d6f92 100644 --- a/KqlMagic.pyproj +++ b/KqlMagic.pyproj @@ -18,7 +18,8 @@ 10.0 - + + @@ -32,6 +33,7 @@ + diff --git a/build_packages.py b/build_packages.py new file mode 100644 index 0000000..04ffaf9 --- /dev/null +++ b/build_packages.py @@ -0,0 +1,74 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +import argparse +import os +from subprocess import check_call +from pathlib import Path +from six import text_type + + +try: + from packaging.version import parse as Version, InvalidVersion +except ImportError: # Should not happen, but at worst in most case this is the same + from pip._vendor.packaging.version import parse as Version, InvalidVersion + +default_destination_folder = os.path.join("..", "dist") +package_list = ["Kqlmagic"] + + +def create_package(name, dest_folder=default_destination_folder): + absdirpath = os.path.abspath(name) + check_call(["python", "setup.py", "bdist_wheel", "-d", dest_folder], cwd=absdirpath) + check_call(["python", "setup.py", "sdist", "-d", dest_folder], cwd=absdirpath) + + +def travis_build_package(): + """Assumed called on Travis, to prepare a package to be deployed + This method prints on stdout for Travis. + Return is obj to pass to sys.exit() directly + """ + travis_tag = os.environ.get("TRAVIS_TAG") + if not travis_tag: + print("TRAVIS_TAG environment variable is not present") + return "TRAVIS_TAG environment variable is not present" + + try: + version = Version(travis_tag) + except InvalidVersion: + failure = "Version must be a valid PEP440 version (version is: {})".format(version) + print(failure) + return failure + + abs_dist_path = Path(os.environ["TRAVIS_BUILD_DIR"], "dist") + [create_package(package, text_type(abs_dist_path)) for package in package_list] + + print("Produced:\n{}".format(list(abs_dist_path.glob("*")))) + + pattern = "*{}*".format(version) + packages = list(abs_dist_path.glob(pattern)) + if not packages: + return "Package version does not match tag {}, abort".format(version) + pypi_server = os.environ.get("PYPI_SERVER", "default PyPI server") + print("Package created as expected and will be pushed to {}".format(pypi_server)) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Build Azure package.") + parser.add_argument("name", help="The package name") + parser.add_argument( + "--dest", + "-d", + default=default_destination_folder, + help="Destination folder. Relative to the package dir. [default: %(default)s]", + ) + + args = parser.parse_args() + if args.name == "all": + for package in package_list: + create_package(package, args.dest) + else: + create_package(args.name, args.dest) diff --git a/setup.py b/setup.py index 328147b..c595566 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,11 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + """Setup for Kqlmagic""" DESCRIPTION = "Kqlmagic: KQL (Kusto Query Language) execution via Jupyter magic" diff --git a/src/kql/__init__.py b/src/kql/__init__.py index 37745c0..bff9262 100644 --- a/src/kql/__init__.py +++ b/src/kql/__init__.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + from .kql_magic import * from .version import VERSION diff --git a/src/kql/ai_client.py b/src/kql/ai_client.py index baeb4aa..80bbdc3 100644 --- a/src/kql/ai_client.py +++ b/src/kql/ai_client.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import six from datetime import timedelta, datetime import re diff --git a/src/kql/ai_engine.py b/src/kql/ai_engine.py index 9c7a607..1ced19a 100644 --- a/src/kql/ai_engine.py +++ b/src/kql/ai_engine.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import os.path import re from kql.kql_engine import KqlEngine, KqlEngineError diff --git a/src/kql/column_guesser.py b/src/kql/column_guesser.py index a8cbeef..767fea2 100644 --- a/src/kql/column_guesser.py +++ b/src/kql/column_guesser.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + from datetime import timedelta, datetime diff --git a/src/kql/connection.py b/src/kql/connection.py index d18be52..8c278f5 100644 --- a/src/kql/connection.py +++ b/src/kql/connection.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import os from kql.kql_engine import KqlEngineError from kql.kusto_engine import KustoEngine diff --git a/src/kql/database_html.py b/src/kql/database_html.py index ba1f374..3368be9 100644 --- a/src/kql/database_html.py +++ b/src/kql/database_html.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + from kql.display import Display from kql.kusto_engine import KustoEngine from kql.ai_engine import AppinsightsEngine diff --git a/src/kql/display.py b/src/kql/display.py index 4da4fa4..d2337bf 100644 --- a/src/kql/display.py +++ b/src/kql/display.py @@ -1,3 +1,8 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- import uuid from IPython.core.display import display, HTML diff --git a/src/kql/file_client.py b/src/kql/file_client.py index b58a05e..5600a34 100644 --- a/src/kql/file_client.py +++ b/src/kql/file_client.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + from kql.kusto_client import KustoResponse import hashlib import json diff --git a/src/kql/file_engine.py b/src/kql/file_engine.py index d67aaf0..5774ce8 100644 --- a/src/kql/file_engine.py +++ b/src/kql/file_engine.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import re import os diff --git a/src/kql/help_html.py b/src/kql/help_html.py index 0f3fb92..fbd9548 100644 --- a/src/kql/help_html.py +++ b/src/kql/help_html.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import time from IPython.core.display import display from IPython.core.magics.display import Javascript diff --git a/src/kql/kql_engine.py b/src/kql/kql_engine.py index 11d141b..68323f8 100644 --- a/src/kql/kql_engine.py +++ b/src/kql/kql_engine.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + from kql.kql_proxy import KqlResponse diff --git a/src/kql/kql_magic.py b/src/kql/kql_magic.py index 2f0e256..4a42a6c 100644 --- a/src/kql/kql_magic.py +++ b/src/kql/kql_magic.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import os import time import logging diff --git a/src/kql/kql_proxy.py b/src/kql/kql_proxy.py index 1c7d278..96d8acb 100644 --- a/src/kql/kql_proxy.py +++ b/src/kql/kql_proxy.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import six import json from kql.display import Display diff --git a/src/kql/kusto_client.py b/src/kql/kusto_client.py index 276cb4b..e7f7e0b 100644 --- a/src/kql/kusto_client.py +++ b/src/kql/kusto_client.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import six from datetime import timedelta, datetime import re diff --git a/src/kql/kusto_engine.py b/src/kql/kusto_engine.py index 3a453d0..1b82b51 100644 --- a/src/kql/kusto_engine.py +++ b/src/kql/kusto_engine.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import re import getpass diff --git a/src/kql/la_client.py b/src/kql/la_client.py index d1cd64a..5871a6e 100644 --- a/src/kql/la_client.py +++ b/src/kql/la_client.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import six from datetime import timedelta, datetime import re diff --git a/src/kql/la_engine.py b/src/kql/la_engine.py index b7c9633..026aca7 100644 --- a/src/kql/la_engine.py +++ b/src/kql/la_engine.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import re from kql.kql_engine import KqlEngine, KqlEngineError from kql.la_client import LoganalyticsClient diff --git a/src/kql/log.py b/src/kql/log.py index 21ff3a9..3c63e39 100644 --- a/src/kql/log.py +++ b/src/kql/log.py @@ -1,29 +1,8 @@ -# ------------------------------------------------------------------------------ -# -# Copyright (c) Microsoft Corporation. -# All rights reserved. -# -# This code is licensed under the MIT License. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files(the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions : -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# -# ------------------------------------------------------------------------------ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- import logging import uuid diff --git a/src/kql/my_aad_helper.py b/src/kql/my_aad_helper.py index 4099f3c..27096a9 100644 --- a/src/kql/my_aad_helper.py +++ b/src/kql/my_aad_helper.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + """ A module to acquire tokens from AAD. """ diff --git a/src/kql/palette.py b/src/kql/palette.py index 87df326..5698ac9 100644 --- a/src/kql/palette.py +++ b/src/kql/palette.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import six from kql.display import Display import seaborn as sns diff --git a/src/kql/parser.py b/src/kql/parser.py index df9622c..8043ec6 100644 --- a/src/kql/parser.py +++ b/src/kql/parser.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + from os.path import expandvars import six from six.moves import configparser as CP diff --git a/src/kql/results.py b/src/kql/results.py index 097cf4d..29e4f49 100644 --- a/src/kql/results.py +++ b/src/kql/results.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import copy import functools import operator diff --git a/src/kql/version.py b/src/kql/version.py index b6582f2..5f1af45 100644 --- a/src/kql/version.py +++ b/src/kql/version.py @@ -1,2 +1,8 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + """ Version file. """ -VERSION = "0.1.33" +VERSION = "0.1.34" diff --git a/src/tests/test_column_guesser.py b/src/tests/test_column_guesser.py index 6b61b9a..37ca7b4 100644 --- a/src/tests/test_column_guesser.py +++ b/src/tests/test_column_guesser.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import re import sys from nose.tools import with_setup, raises diff --git a/src/tests/test_magic.py b/src/tests/test_magic.py index f4eb63d..47eb95f 100644 --- a/src/tests/test_magic.py +++ b/src/tests/test_magic.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + from nose import with_setup from nose.tools import raises from kql.kql_magic import Kqlmagic diff --git a/src/tests/test_parse.py b/src/tests/test_parse.py index 97179b1..a5a0898 100644 --- a/src/tests/test_parse.py +++ b/src/tests/test_parse.py @@ -1,3 +1,9 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + import os from kql.parser import Parser from six.moves import configparser