This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -*- mode: groovy -*- | |
// vim: set filetype=groovy : | |
node( 'some_node' ) { | |
stage( "Phase 1" ) { | |
sshagent( credentials: [ 'some_creds' ] ) { | |
checkout scm | |
def lastSuccessfulCommit = getLastSuccessfulCommit() | |
def currentCommit = commitHashForBuild( currentBuild.rawBuild ) | |
if (lastSuccessfulCommit) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM If you want to set metrics on interfaces go to the confguration of the network interface: | |
REM (THIS IS NOT POSSIBLE WITH THE route COMMAND !!) | |
REM Goto: 'Internet Protocol Version 4 (TCP/IPv4)' -> Properties | |
REM Goto: 'General' -> Advanced | |
REM Goto: 'IP Settings' | |
REM Uncheck 'Automatic metric' | |
REM Type in the metric you want for that interface in 'Interface metric' | |
REM Find out what the interface number is | |
route print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find(find_object, result, keys=[]): | |
if isinstance(find_object, dict): | |
for key, value in find_object.iteritems(): | |
find(value, result, keys + [key]) | |
else: | |
if not(result): | |
result['values'] = [find_object] | |
result['keys'] = [keys] | |
else: | |
result['values'].append(find_object) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic examples | |
>>> var1 = 100 | |
>>> eval("50 + var1") | |
150 | |
>>> eval("var1 = 25") | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "<string>", line 1 | |
var1 = 25 | |
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code below behaves the same as eval() | |
eval(compile(str_source_code, “<string>”, “eval”)) | |
# Code below behaves the same as exec() | |
exec(compile(str_source_code, “<string>”, “exec”)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var = <any valid Python syntax you can place here is an expression> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dbus | |
class dbus_parse(object): | |
__slots__ = ("__dbus_parse_dict", "__parse_dbus_dict", "__parse_dbus_list", "__parse_dbus_tuple", "__parse_dbus_var", "parse_dbus_vars") | |
def __init__(self): | |
self.__dbus_parse_dict = { dbus.String: str, | |
dbus.Int16: int, dbus.Int32: int, dbus.Int64: int, | |
dbus.UInt16: int, dbus.UInt32: int, dbus.UInt64: int, | |
dbus.Double: float, | |
dbus.Boolean: bool, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zip([iterable, ...]) | |
# Example | |
>>> test_list1 = ["a", "b", "c"] | |
>>> test_list2 = [1, 2, 3] | |
>>> zip(test_list1, test_list2) | |
[('a', 1), ('b', 2), ('c', 3)] | |
>>> dict(zip(test_list1, test_list2)) | |
{'a': 1, 'c': 3, 'b': 2} | |
>>> test_list2 = [1, 2, 3, 4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type(object) | |
# Example | |
>>> test_dict = dict() | |
>>> test_int = 0 | |
>>> test_str = "" | |
>>> test_tuple = tuple() | |
>>> test_list = list() | |
>>> type(test_dict) | |
<type 'dict'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isinstance(object, classinfo) | |
# Example | |
>>> test_dict = dict() | |
>>> dict # just showing what is a type object is | |
<type 'dict'> | |
>>> isinstance(test_dict, dict) | |
True | |
>>> isinstance(test_dict, list) | |
False |
NewerOlder