From cb31ea0749c99711c6265e63e3b518e159246a87 Mon Sep 17 00:00:00 2001 From: syphernl Date: Sun, 15 Jan 2012 11:55:02 +0100 Subject: [PATCH 01/84] Apache: Added Debian to the apache2 list Added basic module for nginx support --- salt/modules/apache.py | 4 ++-- salt/modules/nginx.py | 54 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) mode change 100644 => 100755 salt/modules/apache.py create mode 100755 salt/modules/nginx.py diff --git a/salt/modules/apache.py b/salt/modules/apache.py old mode 100644 new mode 100755 index d506cbe61363..a952e90d725c --- a/salt/modules/apache.py +++ b/salt/modules/apache.py @@ -13,8 +13,8 @@ def __detect_os(): ''' Apache commands and paths differ depending on packaging ''' - httpd = ('CentOS', 'Scientific', 'RedHat', 'Fedora') - apache2 = ('Ubuntu',) + httpd = ('CentOS', 'Scientific', 'RedHat', 'Fedora',) + apache2 = ('Ubuntu','Debian',) if __grains__['os'] in httpd: return 'apachectl' elif __grains__['os'] in apache2: diff --git a/salt/modules/nginx.py b/salt/modules/nginx.py new file mode 100755 index 000000000000..0769332e7d01 --- /dev/null +++ b/salt/modules/nginx.py @@ -0,0 +1,54 @@ +''' +Support for nginx +''' + +__outputter__ = { + 'signal': 'txt', +} + +def version(): + ''' + Return server version from nginx -v + + CLI Example:: + + salt '*' nginx.version + ''' + cmd = 'nginx -v' + out = __salt__['cmd.run'](cmd).split('\n') + ret = out[0].split(': ') + return ret[2] + +def signal(signal=None): + ''' + Signals httpd to start, restart, or stop. + + CLI Example:: + + salt '*' nginx.signal reload + ''' + valid_signals = ('reopen', 'stop', 'quit', 'reload') + + if signal not in valid_signals: + return + + # Make sure you use the right arguments + if signal in valid_signals: + arguments = ' -s {0}'.format(signal) + else: + arguments = ' {0}'.format(signal) + cmd = 'nginx' + arguments + out = __salt__['cmd.run_all'](cmd) + + # A non-zero return code means fail + if out['retcode'] and out['stderr']: + ret = out['stderr'].strip() + # 'nginxctl configtest' returns 'Syntax OK' to stderr + elif out['stderr']: + ret = out['stderr'].strip() + elif out['stdout']: + ret = out['stdout'].strip() + # No output for something like: nginxctl graceful + else: + ret = 'Command: "{0}" completed successfully!'.format(cmd) + return ret From 5e16cf756c2cc6d2697b84352ab86c4e8d35f4a7 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sun, 15 Jan 2012 22:39:54 -0600 Subject: [PATCH 02/84] added up, ipaddr, netmask, & hwaddr --- salt/modules/network.py | 118 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/salt/modules/network.py b/salt/modules/network.py index 55bd07f03c67..e844c869c074 100644 --- a/salt/modules/network.py +++ b/salt/modules/network.py @@ -4,6 +4,7 @@ from string import ascii_letters, digits import socket +import re import salt.utils __outputter__ = { @@ -134,3 +135,120 @@ def isportopen(host, port): out = sock.connect_ex((_sanitize_host(host), int(port))) return out + + +def _cidr_to_ipv4_netmask(cidr_bits): + ''' + Returns an IPv4 netmask + ''' + netmask = '' + for n in range(4): + if n: + netmask += '.' + if cidr_bits >= 8: + netmask += '255' + cidr_bits -= 8 + else: + netmask += '%d' % (256-(2**(8-cidr_bits))) + cidr_bits = 0 + return netmask + + +def _interfaces(): + ''' + Returns interface info + + ''' + ret = {} + + out = __salt__['cmd.run']('ip addr show') + groups = re.compile('\r?\n\d').split(out) + + for group in groups: + iface = None + up = False + for line in group.split('\n'): + if not ' ' in line: + continue + m = re.match('^\d*:\s+(\w+):\s+<(.+)>', line) + if m: + iface,attrs = m.groups() + if 'UP' in attrs.split(','): + up = True + ipaddr = None + netmask = None + hwaddr = None + else: + cols = line.split() + if len(cols) >= 2: + type,value = tuple(cols[0:2]) + if type == 'inet': + ipaddr,cidr = tuple(value.split('/')) + netmask = _cidr_to_ipv4_netmask(int(cidr)) + elif type.startswith('link'): + hwaddr = value + + if iface: + ret[iface] = (up,ipaddr,netmask,hwaddr) + del iface,up + + return ret + + +def up(interface): + ''' + Returns True if interface is up, otherwise returns False + + CLI Example:: + + salt '*' network.up eth0 + ''' + data = _interfaces().get(interface) + if data: + return data[0] + else: + return None + +def ipaddr(interface): + ''' + Returns the IP address for a given interface + + CLI Example:: + + salt '*' network.ipaddr eth0 + ''' + data = _interfaces().get(interface) + if data: + return data[1] + else: + return None + +def netmask(interface): + ''' + Returns the netmask for a given interface + + CLI Example:: + + salt '*' network.netmask eth0 + ''' + data = _interfaces().get(interface) + if data: + return data[2] + else: + return None + +def hwaddr(interface): + ''' + Returns the hwaddr for a given interface + + CLI Example:: + + salt '*' network.hwaddr eth0 + ''' + data = _interfaces().get(interface) + if data: + return data[3] + else: + return None + + From b49afa13d5de909ab0eff1259849eac68a8ffb65 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Sun, 15 Jan 2012 22:50:23 -0600 Subject: [PATCH 03/84] fixed hard tabs --- salt/modules/network.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/modules/network.py b/salt/modules/network.py index e844c869c074..c825d27b0009 100644 --- a/salt/modules/network.py +++ b/salt/modules/network.py @@ -165,15 +165,15 @@ def _interfaces(): groups = re.compile('\r?\n\d').split(out) for group in groups: - iface = None - up = False + iface = None + up = False for line in group.split('\n'): if not ' ' in line: continue m = re.match('^\d*:\s+(\w+):\s+<(.+)>', line) if m: iface,attrs = m.groups() - if 'UP' in attrs.split(','): + if 'UP' in attrs.split(','): up = True ipaddr = None netmask = None From 3d4c354e5106f097e40606a5a470a59ce995679c Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Sun, 15 Jan 2012 22:07:02 -0700 Subject: [PATCH 04/84] fix issue where pkg passthrough is broken --- salt/states/pkg.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/salt/states/pkg.py b/salt/states/pkg.py index e3551a16c27a..6f35695f0c7d 100644 --- a/salt/states/pkg.py +++ b/salt/states/pkg.py @@ -42,7 +42,10 @@ def installed(name, repo='', skip_verify=False): 'changes': {}, 'result': True, 'comment': 'Package ' + name + ' is already installed'} - changes = __salt__['pkg.install'](name, True, repo, skip_verify) + changes = __salt__['pkg.install'](name, + True, + repo=repo, + skip_verify=skip_verify) if not changes: return {'name': name, 'changes': changes, @@ -87,7 +90,10 @@ def latest(name, repo='', skip_verify=False): return ret if has_newer: - ret['changes'] = __salt__['pkg.install'](name, True, repo, skip_verify) + ret['changes'] = __salt__['pkg.install'](name, + True, + repo=repo, + skip_verify=skip_verify) if ret['changes']: ret['comment'] = 'Package {0} upgraded to latest'.format(name) From eb3dc17d9f9b7dce7a959fd20ae0de61238fd716 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Sun, 15 Jan 2012 22:07:24 -0700 Subject: [PATCH 05/84] make cache_file check non-salt servers --- salt/minion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/minion.py b/salt/minion.py index ce53e1071771..7a4ca093f131 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -722,7 +722,7 @@ def cache_file(self, path, env='base'): Pull a file down from the file server and store it in the minion file cache ''' - return self.get_file(path, '', True, env) + return self.get_url(path, '', True, env) def cache_files(self, paths, env='base'): ''' From 401040fd5f1119972226c9bceb71cfc4f5697b68 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Mon, 16 Jan 2012 13:07:02 +0800 Subject: [PATCH 06/84] fix issue where pkg passthrough is broken --- salt/states/pkg.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/salt/states/pkg.py b/salt/states/pkg.py index ff5dfa10630b..60d6fe8ab74f 100644 --- a/salt/states/pkg.py +++ b/salt/states/pkg.py @@ -42,7 +42,10 @@ def installed(name, repo='', skip_verify=False): 'changes': {}, 'result': True, 'comment': 'Package ' + name + ' is already installed'} - changes = __salt__['pkg.install'](name, True, repo, skip_verify) + changes = __salt__['pkg.install'](name, + True, + repo=repo, + skip_verify=skip_verify) if not changes: return {'name': name, 'changes': changes, @@ -87,7 +90,10 @@ def latest(name, repo='', skip_verify=False): return ret if has_newer: - ret['changes'] = __salt__['pkg.install'](name, True, repo, skip_verify) + ret['changes'] = __salt__['pkg.install'](name, + True, + repo=repo, + skip_verify=skip_verify) if ret['changes']: ret['comment'] = 'Package {0} upgraded to latest'.format(name) From 270097027205be7a95eeeec1466f1523dd50f2cc Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Mon, 16 Jan 2012 13:07:24 +0800 Subject: [PATCH 07/84] make cache_file check non-salt servers --- salt/minion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/minion.py b/salt/minion.py index ce53e1071771..7a4ca093f131 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -722,7 +722,7 @@ def cache_file(self, path, env='base'): Pull a file down from the file server and store it in the minion file cache ''' - return self.get_file(path, '', True, env) + return self.get_url(path, '', True, env) def cache_files(self, paths, env='base'): ''' From e566f42f955616e91463f04190f66dc57d0d3463 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Sun, 15 Jan 2012 23:02:39 -0700 Subject: [PATCH 08/84] update to handle alternative source hash files --- salt/states/file.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index 49494bf633bb..fed69ab82307 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -327,6 +327,7 @@ def absent(name): def managed(name, source=None, + source_hash=None, user=None, group=None, mode=None, @@ -423,11 +424,30 @@ def managed(name, else: # Copy the file down if there is a source if source: - source_sum = __salt__['cp.hash_file'](source, __env__) - if not source_sum: - ret['result'] = False - ret['comment'] = 'Source file {0} not found'.format(source) - return ret + if urlparse.urlparse(source).scheme == 'salt': + source_sum = __salt__['cp.hash_file'](source, __env__) + if not source_sum: + ret['result'] = False + ret['comment'] = ('Checksum for source file {0} not' + ' found').format(source) + return ret + else: + # This file is not on a salt file server + sum_file = __salt__['cp.cahe_file'](source_hash) + if not sum_file: + ret['result'] = False + ret['comment'] = ('Checksum for source file {0} not' + ' found').format(source) + return ret + comps = open(sum_source, 'r').read().split('=') + if len(comps) < 2: + ret['result'] = False + ret['comment'] = ('Checksum for source file {0} not' + ' formatted properly').format(source) + return ret + source_sum['hash_type'] = comps[0] + source_sum['hsum'] = comps[1] + # If the source file is a template render it accordingly # Check changes if the target file exists From 74d0c7f0cafef92584bb2d9d298152bd93502457 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Sun, 15 Jan 2012 23:29:23 -0700 Subject: [PATCH 09/84] revert to get_file, get_url still needs work --- salt/minion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/minion.py b/salt/minion.py index 7a4ca093f131..ce53e1071771 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -722,7 +722,7 @@ def cache_file(self, path, env='base'): Pull a file down from the file server and store it in the minion file cache ''' - return self.get_url(path, '', True, env) + return self.get_file(path, '', True, env) def cache_files(self, paths, env='base'): ''' From fb85eafa2a60c344dd889227b91fe259f88e6bf2 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Sun, 15 Jan 2012 23:33:26 -0700 Subject: [PATCH 10/84] fixes towards accepting more sources for a file --- salt/states/file.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index fed69ab82307..205ba8c566ea 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -72,6 +72,7 @@ import logging import tempfile import traceback +import urlparse logger = logging.getLogger(__name__) @@ -327,7 +328,7 @@ def absent(name): def managed(name, source=None, - source_hash=None, + source_hash='', user=None, group=None, mode=None, @@ -433,7 +434,7 @@ def managed(name, return ret else: # This file is not on a salt file server - sum_file = __salt__['cp.cahe_file'](source_hash) + sum_file = __salt__['cp.cache_file'](source_hash) if not sum_file: ret['result'] = False ret['comment'] = ('Checksum for source file {0} not' From 1dd8120dab6cdec4097bea1193a5b5b68d3bfe4f Mon Sep 17 00:00:00 2001 From: David Boucha Date: Sun, 15 Jan 2012 23:47:04 -0700 Subject: [PATCH 11/84] Add Windows support to group add Add, remove and get info on Local Windows Groups --- salt/modules/win_groupadd.py | 90 ++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 salt/modules/win_groupadd.py diff --git a/salt/modules/win_groupadd.py b/salt/modules/win_groupadd.py new file mode 100644 index 000000000000..9144bf348044 --- /dev/null +++ b/salt/modules/win_groupadd.py @@ -0,0 +1,90 @@ +''' +Manage groups on Windows +''' + +def __virtual__(): + ''' + Set the group module if the kernel is Windows + ''' + return 'group' if __grains__['kernel'] == 'Windows' else False + + +def add(name): + ''' + Add the specified group + + CLI Example:: + + salt '*' group.add foo + ''' + cmd = 'net localgroup {0} /add'.format(name) + + ret = __salt__['cmd.run_all'](cmd) + + return not ret['retcode'] + + +def delete(name): + ''' + Remove the named group + + CLI Example:: + + salt '*' group.delete foo + ''' + ret = __salt__['cmd.run_all']('net localgroup {0} /delete'.format(name)) + + return not ret['retcode'] + + +def info(name): + ''' + Return information about a group + + CLI Example:: + + salt '*' group.info foo + ''' + lines = __salt__['cmd.run']('net localgroup {0}'.format(name)).split('\n') + memberline = False + gr_mem = [] + gr_name = '' + for line in lines: + if 'Alias name' in line: + comps = line.split(' ', 1) + gr_name = comps[1].strip() + if 'successfully' in line: + memberline = False + if memberline: + gr_mem.append(line.strip()) + if '---' in line: + memberline = True + if not gr_name: + return False + + return {'name': gr_name, + 'passwd': None, + 'gid': None, + 'members': gr_mem} + + +def getent(): + ''' + Return info on all groups + + CLI Example:: + + salt '*' group.getent + ''' + ret = [] + lines = __salt__['cmd.run']('net localgroup').split('\n') + groupline = False + for line in lines: + if 'successfully' in line: + groupline = False + if groupline: + ret.append(line.strip('*').strip()) + if '---' in line: + groupline = True + + return ret From 105ed6d70cb04bba23a2287453706af7adcf7bb9 Mon Sep 17 00:00:00 2001 From: Seth House Date: Mon, 16 Jan 2012 01:45:05 -0700 Subject: [PATCH 12/84] Added pyyaml to the list of mocked imports for the docs --- doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/conf.py b/doc/conf.py index 6e2b486ccc79..b647dcc08a83 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -29,6 +29,7 @@ def __getattr__(self, name): MOCK_MODULES = [ # salt core + 'yaml', 'salt.msgpack._msgpack', 'zmq', 'Crypto', From 4e3aacc81335eb0eca91532c16b4a1fc0f1b9dda Mon Sep 17 00:00:00 2001 From: Seth House Date: Mon, 16 Jan 2012 02:14:22 -0700 Subject: [PATCH 13/84] Slight modifications to docs in preparation for rtfd.org Moved the html customizations into a proper theme and cleaned up the configs to be useful for the default theme. --- doc/_static/salt-vert.png | Bin 0 -> 3488 bytes doc/_templates/layout.html | 192 +----------------- doc/_themes/saltstack/layout.html | 186 +++++++++++++++++ .../saltstack/static}/base-salt.css | 0 .../saltstack/static/salt-horiz.png} | Bin doc/_themes/saltstack/theme.conf | 3 + doc/conf.py | 12 +- 7 files changed, 203 insertions(+), 190 deletions(-) create mode 100644 doc/_static/salt-vert.png create mode 100644 doc/_themes/saltstack/layout.html rename doc/{_static => _themes/saltstack/static}/base-salt.css (100%) rename doc/{_static/salt.png => _themes/saltstack/static/salt-horiz.png} (100%) create mode 100644 doc/_themes/saltstack/theme.conf diff --git a/doc/_static/salt-vert.png b/doc/_static/salt-vert.png new file mode 100644 index 0000000000000000000000000000000000000000..1033eef4b43a3758b70c6d19286721becfc1f68b GIT binary patch literal 3488 zcmV;R4PWw!P)Px%h)_&aMF5Dh0E)B%jR2x65j_(QLQUa< z(%-1i-=fptsnOu0)Zwbq;jz)-q}Af9)8ewy;-%K(tkvVQ)8nnyA2YGwc6vn*yFO>>b=?Ix!UTq-0Qd8<-XeGwcYHw-R8gC=DObJ zz}@G&-{`^K=)B;_AfU>&4;hzvS)4;_b)d?#<%v$mH+IFw9(@6qb-((CZq>G0F+@!IO~)a~-y>+;p^^W5z7*YEV*?)2X8 z_22OJ;PLq5@$upE`Q`HS>GAsJ^YrBO`|a}e=k)dN^Y-ZV_UZQb@Adca_W1Jm`SbYu z^!fbt`u+C%{`dX=`~CX({{R2|`~Us_`Tzg?|NH*`{Bdo?EdT%j0b)x>L;#2d9Y_EG z010qNS#tmY4c7nw4c7reD4Tcy000McNliru+yM{?AqYvtu7v;q3Xw@fK~!ko?VA5@ zQ`Z&1BjWW{)$^CMmhzQ?!c-b9(y|zl_jX^OR6(3X9;`6hwP+)fmo1}9Vbq`~WHYn< z5=Rk}P_(A3r6htS1=jip8b!gjri?9xeDRlfNd9+r?)(1bKHDje3ZxtfVqf2P-{+ol z?mg$+_v*?owAAh5@8a*`@8a*`KMj82Q8tr(l(X+%+Str}FI?Xi2{*5dpA8@7vGfki zY}e{+KQc+e z58FpMG-JgNa0Eezs=0~0{C;w;>UC%#Bf~C zf_3O)2=R!!T`PX+?mbx+7>-#~zTB+uO@&S%1R$s8&b3!~J=maeA?{BY)npd0R!auf6_&J_K3H?Bu z;dSfi0|?EOcrK8BHuzg#U5N>1iASSxb6afk>%0L!!*lGzYQryq<8PKD2!);r{+9+N z>$Od4`$~_0pQ}MT=MWnym(#Ee(~jd8?oVE^a*p+nPm!jC7x&N;4IdQCY*wMqA4Uix z97ibPH2$(6kTB0Tcn7A4^ym5RCkE$1x2oU|v)qUn-5@>`9K}yxixPDV_%ziVj7`Q( z%Xz4uMSA>PFUR#&_MUZ^VM_e;9>-pA5Pxk_u#@u*ZV=zkjQr;b%Yp6It`1GA8qCpv5`0IdUln%3}}tK(zWNGJIo z@S$b>{=gt!Un{(i&{-$&-EPYJ=FruI9e=o!qIZZ7={4jB#?0ol3HMfUq&AFs+c z?JY2Q@pZRifg16#Bzw3(MvE-4R__~D@^KD@9m0nRcn*fI*?G|9;6d2}JHRglxgM?F zN~$4Ckr@bGkDbED7C1N>v$Md|P^+6ZyBzyxohKbLcbH)j?<799z=2Wg8i)(Av3~T10Ut`%!3{&T zb;5KmQ4Dg7l7i-g9I_PdP@gd~j^g7r@I%WQm>%wjecXVLn8>QJSR6*|g26d%Fi5>$ z3gWQ!-b0A%D>#cUu7QiH1rnh7k9jdoIH2N#=FhB~O7(0v5Wc&lon+0!#yPH?FR+AD zlQiV051ht_P14gIzABxR2-D#pk~Ge`XbB(nTw1jrlq^9%#Dwl{YR(1%`f*W#| z2LX=H6Of?lI<3c#tQckayWmR}_@j7A@)4&vI~%>Y&r3Ih=0g+s_^@O?DA~Hq;DnR! z3xz^>%7|Z6x|~30h;+UPnFEv7@ZoBs{P;WKV+-sLPydS7vP*VcnEEi#$ebD#gxKHG zq(j2=8R(BB_hR`$Ro_`2F)Jj8D25RFK*8@t7Ws)DzY86z8DE@1w|?*!lNJ**cpCYnD_j=@!`u6+9Z@3N0SupIB22|dlheh zzkB7JX+L~*$+5W?oSmk%6C_^+{6jm!57*1L#X|XuBED%z4Zl+=?~L@llp$+zFPQPe z6mHg?jy6=l59|a#i$|id;qi#BIo$R(B`IB;mZ*J2-COc3f2XJKl6op*xIHNo{s?ZT z^y{J$ez!e-z>=~h@yMNE*0sx>6x}D4EDinZU`pz;b@&;w1<3eJUoua6DIkntyfm?8ILnvy+2A{g`$Fm!< z3tt2aSn-))(i&1_{9+TWY@Dx6RKXX|T&|ZhcoxlaJ)iR8i_13nG#;I%AKS;@RI|wf zW_-jZ3FWrB?`QWayEfS1ua)qZL@$TM*om3sgTh4*e)?gDFC_a@aJn?H570{$`VG$-YG(ED}xEw=dPut$`|CfWucowIx7smnMwCwkjlk_zY*Tl^XVCSLi@hLG*Q#UK8a5@WU_$(J&BfbbmNSGg=ZornNM{M!M=p#K> zJVmJb^ge9(O5_gqx`Q|cr^ku+6XviBYjwGXG6pQ*>1I)^>KjH1{wb`x#>nG*epdAT2^;*9UisxB zW|p#>(t=of(Edm|Ev-Ob+MFkgfuUNC%Ow1JKai7MTFQ1k>o)iy%21}@ zOou)oS@<%gCd^_8p@z-)s~+6p?b-^-M>X}5wf~m}UDTtgS(|-7C(dojRBX$MTEwd# zgAQ7&ty_48uB3y-zOr=FA-T!`c>i^~s2jt-AJji$!HZYfrtWko=S~p0KPy}D#l+U_ zzVAFfc<(b;|fZh0hK8dTF%{T70UP&Ue5NzJ^!ZH4S&*4hsHu zYZD&rS>R*eSWRcwpKiQdc6m9wRi)Gao(=wsC%gE&_`CSK_`CQ!l>Y;st+Y_kJtXu1 O0000r literal 0 HcmV?d00001 diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html index c194dcc99bc7..87ec3add61ab 100644 --- a/doc/_templates/layout.html +++ b/doc/_templates/layout.html @@ -1,188 +1,6 @@ -{%- block doctype -%} - -{%- endblock %} +{% extends "!layout.html" %} -{%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %} -{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} -{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and (sidebars != []) %} -{%- set url_root = pathto('', 1) %} -{# XXX necessary? #} -{%- if url_root == '#' %}{% set url_root = '' %}{% endif %} -{%- if not embedded and docstitle %} - {%- set titlesuffix = " — "|safe + docstitle|e %} -{%- else %} - {%- set titlesuffix = "" %} -{%- endif %} - -{%- macro relbar() %} - -{%- endmacro %} - -{%- macro sidebar() %} - {%- if render_sidebar %} - - {%- endif %} -{%- endmacro %} - -{%- macro script() %} - - {%- for scriptfile in script_files %} - - {%- endfor %} -{%- endmacro %} - -{%- macro css() %} - - {% for s in style %} - - {% endfor %} - -{%- endmacro %} - - - - - {{ metatags }} - - {%- block htmltitle %} - {{ title|striptags|e }}{{ titlesuffix }} - {%- endblock %} - - {{ css() }} - - {%- if not embedded %} - {{ script() }} - {%- if use_opensearch %} - - {%- endif %} - - {%- if favicon %} - - {%- endif %} - {%- endif %} - - {%- block linktags %} - {%- if hasdoc('about') %} - - {%- endif %} - {%- if hasdoc('genindex') %} - - {%- endif %} - {%- if hasdoc('search') %} - - {%- endif %} - {%- if hasdoc('copyright') %} - - {%- endif %} - - {%- if parents %} - - {%- endif %} - {%- if next %} - - {%- endif %} - {%- if prev %} - - {%- endif %} - {%- endblock %} - - {%- block extrahead %} {% endblock %} - - {%- block analytics %} - - {% endblock %} - -
- {% block header %} - {%- if logo %} -
-

- Salt Stack -

-
- {%- endif %} - {% endblock %} - - {%- block relbar1 %}{{ relbar() }}{% endblock %} - - {%- block content %} - - {%- block sidebar1 %}{% endblock %} - -
-
- {%- block document %} - {% block body %} {% endblock %} - {%- endblock %} -
- - {%- block sidebar2 %}{{ sidebar() }}{% endblock %} -
- {%- endblock %} - - {%- block relbar2 %}{{ relbar() }}{% endblock %} - - {%- block footer %} - - {%- endblock %} - - +{% block rootrellink %} +
  • Salt home | 
  • +
  • Documentation »
  • +{% endblock %} diff --git a/doc/_themes/saltstack/layout.html b/doc/_themes/saltstack/layout.html new file mode 100644 index 000000000000..0e6db08e9f49 --- /dev/null +++ b/doc/_themes/saltstack/layout.html @@ -0,0 +1,186 @@ +{%- block doctype -%} + +{%- endblock %} + +{%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %} +{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} +{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and (sidebars != []) %} +{%- set url_root = pathto('', 1) %} +{# XXX necessary? #} +{%- if url_root == '#' %}{% set url_root = '' %}{% endif %} +{%- if not embedded and docstitle %} + {%- set titlesuffix = " — "|safe + docstitle|e %} +{%- else %} + {%- set titlesuffix = "" %} +{%- endif %} + +{%- macro relbar() %} + +{%- endmacro %} + +{%- macro sidebar() %} + {%- if render_sidebar %} + + {%- endif %} +{%- endmacro %} + +{%- macro script() %} + + {%- for scriptfile in script_files %} + + {%- endfor %} +{%- endmacro %} + +{%- macro css() %} + + {% if style %} + + {% endif %} + +{%- endmacro %} + + + + + {{ metatags }} + + {%- block htmltitle %} + {{ title|striptags|e }}{{ titlesuffix }} + {%- endblock %} + + {{ css() }} + + {%- if not embedded %} + {{ script() }} + {%- if use_opensearch %} + + {%- endif %} + + {%- if favicon %} + + {%- endif %} + {%- endif %} + + {%- block linktags %} + {%- if hasdoc('about') %} + + {%- endif %} + {%- if hasdoc('genindex') %} + + {%- endif %} + {%- if hasdoc('search') %} + + {%- endif %} + {%- if hasdoc('copyright') %} + + {%- endif %} + + {%- if parents %} + + {%- endif %} + {%- if next %} + + {%- endif %} + {%- if prev %} + + {%- endif %} + {%- endblock %} + + {%- block extrahead %} {% endblock %} + + {%- block analytics %} + + {% endblock %} + +
    + {% block header %} +
    +

    + Salt Stack +

    +
    + {% endblock %} + + {%- block relbar1 %}{{ relbar() }}{% endblock %} + + {%- block content %} + + {%- block sidebar1 %}{% endblock %} + +
    +
    + {%- block document %} + {% block body %} {% endblock %} + {%- endblock %} +
    + + {%- block sidebar2 %}{{ sidebar() }}{% endblock %} +
    + {%- endblock %} + + {%- block relbar2 %}{{ relbar() }}{% endblock %} + + {%- block footer %} + + {%- endblock %} + + diff --git a/doc/_static/base-salt.css b/doc/_themes/saltstack/static/base-salt.css similarity index 100% rename from doc/_static/base-salt.css rename to doc/_themes/saltstack/static/base-salt.css diff --git a/doc/_static/salt.png b/doc/_themes/saltstack/static/salt-horiz.png similarity index 100% rename from doc/_static/salt.png rename to doc/_themes/saltstack/static/salt-horiz.png diff --git a/doc/_themes/saltstack/theme.conf b/doc/_themes/saltstack/theme.conf new file mode 100644 index 000000000000..347566bd03f4 --- /dev/null +++ b/doc/_themes/saltstack/theme.conf @@ -0,0 +1,3 @@ +[theme] +inherit = default +stylesheet = base-salt.css diff --git a/doc/conf.py b/doc/conf.py index b647dcc08a83..26aae63ea426 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -69,6 +69,8 @@ def __getattr__(self, name): from salt.version import __version__ +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' + # -- General configuration ----------------------------------------------------- project = u'Salt' @@ -108,14 +110,18 @@ def __getattr__(self, name): ### HTML options -html_theme = 'default' +if on_rtd: + html_theme = 'default' +else: + html_theme = 'saltstack' + +html_theme_path = ['_themes'] html_title = None html_short_title = 'Salt' html_static_path = ['_static'] -html_logo = 'salt.png' +html_logo = 'salt-vert.png' html_favicon = 'favicon.ico' -html_style = ['base-salt.css'] html_use_smartypants = False html_additional_pages = { From 7f3095567588ea486ce182583f3c91b027e653c5 Mon Sep 17 00:00:00 2001 From: Jeff Bauer Date: Mon, 16 Jan 2012 13:29:49 -0600 Subject: [PATCH 14/84] rename conf files to templates, issue #518 --- conf/{master => master.template} | 0 conf/{minion => minion.template} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename conf/{master => master.template} (100%) rename conf/{minion => minion.template} (100%) diff --git a/conf/master b/conf/master.template similarity index 100% rename from conf/master rename to conf/master.template diff --git a/conf/minion b/conf/minion.template similarity index 100% rename from conf/minion rename to conf/minion.template From 94a8b927ded4a39659674f4e53e3be02de515635 Mon Sep 17 00:00:00 2001 From: Jeff Bauer Date: Mon, 16 Jan 2012 13:36:39 -0600 Subject: [PATCH 15/84] added salt/config.py, setup.py changes --- conf/master.template | 7 ++++--- conf/minion.template | 1 + salt/config.py | 13 +++++++++++-- setup.py | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/conf/master.template b/conf/master.template index 01248da7464f..2aaf88313160 100644 --- a/conf/master.template +++ b/conf/master.template @@ -1,3 +1,4 @@ +# DO NOT MODIFY THIS FILE. Copy it to: /etc/salt/master ##### Primary configuration settings ##### ########################################## # The address of the interface to bind to @@ -85,9 +86,9 @@ # prod: # - /srv/salt/prod/services # - /srv/salt/prod/states -# +# # Default: -#file_roots: +#file_roots: # base: # - /srv/salt @@ -183,7 +184,7 @@ ########################################## # Node groups allow for logical groupings of minion nodes. # A group consists of a group name and a compound target. -# +# # nodegroups: # group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com', # group2: 'G@os:Debian and foo.domain.com', diff --git a/conf/minion.template b/conf/minion.template index ac8ad9d04d1a..669ff76f6c12 100644 --- a/conf/minion.template +++ b/conf/minion.template @@ -1,3 +1,4 @@ +# DO NOT MODIFY THIS FILE. Copy it to: /etc/salt/minion ##### Primary configuration settings ##### ########################################## # Set the location of the salt master server, if the master server cannot be diff --git a/salt/config.py b/salt/config.py index 731c4191dcac..5863c444ca9a 100644 --- a/salt/config.py +++ b/salt/config.py @@ -30,7 +30,16 @@ def load_config(opts, path, env_var): ''' if not path or not os.path.isfile(path): - path = os.environ.get(env_var, '') + path = os.environ.get(env_var, path) + # If the configuration file is missing, attempt to copy the template, + # after removing the first header line. + if not os.path.isfile(path): + template = "%s.template" % path + if os.path.isfile(template): + with open(path, 'w') as out: + with open(template, 'r') as f: + f.readline() # skip first line + out.write(f.read()) if os.path.isfile(path): try: @@ -112,7 +121,7 @@ def minion_config(path): # set up the extension_modules location from the cachedir opts['extension_modules'] = os.path.join(opts['cachedir'], 'extmods') - + return opts diff --git a/setup.py b/setup.py index 6d3830ad7f05..5f0d2a7de4aa 100755 --- a/setup.py +++ b/setup.py @@ -122,8 +122,8 @@ def __init__(self, *args, **kwargs): 'scripts/salt-run', 'scripts/salt'], data_files=[(os.path.join(etc_path, 'salt'), - ['conf/master', - 'conf/minion', + ['conf/master.template', + 'conf/minion.template', ]), ('share/man/man1', ['doc/man/salt-master.1', From 470038b2cc94743885c4c6b5aa11e5d50d71ad1b Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Mon, 16 Jan 2012 15:36:59 -0800 Subject: [PATCH 16/84] Applying latest changes for packaging --- debian/changelog | 2 +- debian/control | 28 +++++++++++++++++++--------- debian/salt-common.install | 1 - debian/salt-master.install | 2 +- debian/salt-minion.install | 4 ++-- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/debian/changelog b/debian/changelog index 52368b3f1704..719d4de5c145 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -salt (0.9.5+git20111227.g8182e48-1) unstable; urgency=low +salt (0.9.5-1) unstable; urgency=low * First package release. (Closes: #643789) diff --git a/debian/control b/debian/control index b353685884b8..df920afbb37f 100644 --- a/debian/control +++ b/debian/control @@ -11,7 +11,6 @@ Build-Depends: debhelper (>= 7.0.50~), python-crypto, python-m2crypto, python-zmq (>= 2.1.9), - libzmq1 (>= 2.1.9), libzmq-dev (>= 2.1.9), python (>= 2.6), python-dev (>= 2.6), @@ -24,8 +23,20 @@ Homepage: http://saltstack.org Package: salt-common Architecture: any -Depends: ${python:Depends}, - ${misc:Depends} +Depends: ${python:Depends}, + ${misc:Depends}, + python-support, + cython, + python-yaml, + python-setuptools, + python-yaml, + python-crypto, + python-m2crypto, + python-zmq (>= 2.1.9), + libzmq-dev (>= 2.1.9), + python (>= 2.6), + python-dev (>= 2.6), + python-jinja2 Description: Shared libraries that salt requires for all packages This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -41,15 +52,14 @@ Description: Shared libraries that salt requires for all packages Between the remote execution system, and state management Salt addresses the backbone of cloud and data center management. . - This particular package provides shared libraries that salt-master, salt-minion, - and salt-syndic require to function. - + This particular package provides shared libraries that salt-master, + salt-minion, and salt-syndic require to function. Package: salt-master Architecture: all Depends: ${python:Depends}, ${misc:Depends}, - salt-common + salt-common (= ${binary:Version}) Description: This package provides a remote manager to administer servers via salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -72,7 +82,7 @@ Package: salt-minion Architecture: all Depends: ${python:Depends}, ${misc:Depends}, - salt-common + salt-common (= ${binary:Version}) Description: This package represents the client package for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -96,7 +106,7 @@ Architecture: all Depends: ${python:Depends}, ${misc:Depends}, salt-master -Description: salt-syndic represents the master-of-masters for salt +Description: The syndic component represents the master-of-masters for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. . diff --git a/debian/salt-common.install b/debian/salt-common.install index 8ef4a2454ea8..037a3fb7c9dd 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -5,5 +5,4 @@ usr/share/man/man1/salt-master.1 usr/share/man/man1/salt-syndic.1 usr/share/man/man1/salt-cp.1 usr/share/man/man1/salt.1 -conf/minion /etc/salt/minion salt/* /usr/share/salt/ diff --git a/debian/salt-master.install b/debian/salt-master.install index 53d4c1340db6..9d418d39bd66 100644 --- a/debian/salt-master.install +++ b/debian/salt-master.install @@ -1 +1 @@ -conf/master /etc/salt/master +conf/master.template /etc/salt/master diff --git a/debian/salt-minion.install b/debian/salt-minion.install index 7ed61cee7ef1..d882649e286b 100644 --- a/debian/salt-minion.install +++ b/debian/salt-minion.install @@ -1,4 +1,4 @@ scripts/salt-minion /usr/share/salt/salt-minion scripts/salt-call /usr/share/salt/salt-call -modules/* /usr/share/salt/modules/ -conf/minion /etc/salt/minion +salt/modules/* /usr/share/salt/modules/ +conf/minion.template /etc/salt/minion From fff251735b4ddcb31e2ff857abb51871cfd973e8 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Mon, 16 Jan 2012 15:52:27 -0800 Subject: [PATCH 17/84] Fixed typos in man pages --- debian/control | 3 +++ doc/man/salt-cp.1 | 6 +++--- doc/man/salt.7 | 6 +++--- doc/ref/cli/salt-cp.rst | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/debian/control b/debian/control index df920afbb37f..2bda3f6e6ebd 100644 --- a/debian/control +++ b/debian/control @@ -59,6 +59,7 @@ Package: salt-master Architecture: all Depends: ${python:Depends}, ${misc:Depends}, + python (>= 2.6), salt-common (= ${binary:Version}) Description: This package provides a remote manager to administer servers via salt This package is a powerful remote execution manager that can be used @@ -82,6 +83,7 @@ Package: salt-minion Architecture: all Depends: ${python:Depends}, ${misc:Depends}, + python (>= 2.6), salt-common (= ${binary:Version}) Description: This package represents the client package for salt This package is a powerful remote execution manager that can be used @@ -105,6 +107,7 @@ Package: salt-syndic Architecture: all Depends: ${python:Depends}, ${misc:Depends}, + python (>= 2.6), salt-master Description: The syndic component represents the master-of-masters for salt This package is a powerful remote execution manager that can be used diff --git a/doc/man/salt-cp.1 b/doc/man/salt-cp.1 index e0196f6f49d8..71d01834d2cd 100644 --- a/doc/man/salt-cp.1 +++ b/doc/man/salt-cp.1 @@ -61,7 +61,7 @@ The timeout in seconds to wait for replies from the salt minions. .INDENT 0.0 .TP .B \-E, \-\-pcre -The target expresion will be interpereted as a pcre regular expression +The target expression will be interpereted as a pcre regular expression rather than a shell glob. .UNINDENT .INDENT 0.0 @@ -74,8 +74,8 @@ example: server1.foo.bar,server2.foo.bar,example7.quo.qux .TP .B \-G, \-\-grain The target expression matches values returned by the salt grains system on -the minions. The target expresion is in the format of \(aq:\(aq; example: \(aqos:Arch.*\(aq +the minions. The target expression is in the format of \(aq:\(aq; example: \(aqos:Arch.*\(aq .UNINDENT .INDENT 0.0 .TP diff --git a/doc/man/salt.7 b/doc/man/salt.7 index 7545aabab458..fd89a7bcf7fa 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -9443,7 +9443,7 @@ The timeout in seconds to wait for replies from the salt minions. .INDENT 0.0 .TP .B \-E, \-\-pcre -The target expresion will be interpereted as a pcre regular expression +The target expression will be interpereted as a pcre regular expression rather than a shell glob. .UNINDENT .INDENT 0.0 @@ -9456,8 +9456,8 @@ example: server1.foo.bar,server2.foo.bar,example7.quo.qux .TP .B \-G, \-\-grain The target expression matches values returned by the salt grains system on -the minions. The target expresion is in the format of \(aq:\(aq; example: \(aqos:Arch.*\(aq +the minions. The target expression is in the format of \(aq:\(aq; example: \(aqos:Arch.*\(aq .UNINDENT .INDENT 0.0 .TP diff --git a/doc/ref/cli/salt-cp.rst b/doc/ref/cli/salt-cp.rst index 977aec2dd48d..de338d9a35ef 100644 --- a/doc/ref/cli/salt-cp.rst +++ b/doc/ref/cli/salt-cp.rst @@ -36,7 +36,7 @@ Options .. option:: -E, --pcre - The target expresion will be interpereted as a pcre regular expression + The target expression will be interpereted as a pcre regular expression rather than a shell glob. .. option:: -L, --list @@ -47,8 +47,8 @@ Options .. option:: -G, --grain The target expression matches values returned by the salt grains system on - the minions. The target expresion is in the format of ':'; example: 'os:Arch.*' + the minions. The target expression is in the format of ':'; example: 'os:Arch.*' .. option:: -Q, --query From 1b2555a13830af1bb85df78722cea09eda2c10c8 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Mon, 16 Jan 2012 16:12:53 -0800 Subject: [PATCH 18/84] Latest round of changes --- debian/control | 6 +++--- debian/{salt.manpages => salt-common.manpages} | 0 doc/man/salt.7 | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) rename debian/{salt.manpages => salt-common.manpages} (100%) diff --git a/debian/control b/debian/control index 2bda3f6e6ebd..7960077a9907 100644 --- a/debian/control +++ b/debian/control @@ -83,7 +83,7 @@ Package: salt-minion Architecture: all Depends: ${python:Depends}, ${misc:Depends}, - python (>= 2.6), + python, salt-common (= ${binary:Version}) Description: This package represents the client package for salt This package is a powerful remote execution manager that can be used @@ -124,5 +124,5 @@ Description: The syndic component represents the master-of-masters for salt Between the remote execution system, and state management Salt addresses the backbone of cloud and data center management. . - This particular package provides the master of masters for salt-- it enables the management - of multiple masters at a time. + This particular package provides the master of masters for salt-- it enables + the management of multiple masters at a time. diff --git a/debian/salt.manpages b/debian/salt-common.manpages similarity index 100% rename from debian/salt.manpages rename to debian/salt-common.manpages diff --git a/doc/man/salt.7 b/doc/man/salt.7 index fd89a7bcf7fa..0f9d1c7253e4 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -7827,7 +7827,7 @@ extra information needs to be sent with the publications, the order_masters option makes sure that the extra data is sent out. .SS Running the Syndic .sp -The Syndic is a seperate daemon that needs to be started on the master that is +The Syndic is a separate daemon that needs to be started on the master that is controlled by a higher master. Starting the Syndic daemon is the same as starting the other Salt daemons. .sp @@ -8149,7 +8149,7 @@ def get_file(path, dest, env=\(aqbase\(aq): # syndic servers(s) below it set the "order_masters" setting to True, if this # is a master that will be running a syndic daemon for passthrough the # "syndic_master" setting needs to be set to the location of the master server -# to recieve commands from +# to receive commands from # # Set the order_masters setting to True if this master will command lower # masters\(aq syndic interfaces @@ -8608,7 +8608,7 @@ master. Using the syndic is simple, if this is a master that will have syndic servers(s) below it set the "order_masters" setting to True, if this is a master that will be running a syndic daemon for passthrough the "syndic_master" setting needs to be set to the location of the master server -to recieve commands from +to receive commands from .SS \fBorder_masters\fP .sp Default: \fBFalse\fP @@ -11192,5 +11192,4 @@ Thomas S. Hatch and many others, please see the Authors file .SH COPYRIGHT 2011, Thomas S. Hatch .\" Generated by docutils manpage writer. -.\" . From b4b0e1a7c34d55089bdc36447e569aa51f0a3cca Mon Sep 17 00:00:00 2001 From: Seth House Date: Mon, 16 Jan 2012 17:27:04 -0700 Subject: [PATCH 19/84] Fixed various reST stuffs in the 0.9.5 release notes --- doc/topics/releases/0.9.5.rst | 213 ++++++++++++++++++---------------- 1 file changed, 114 insertions(+), 99 deletions(-) diff --git a/doc/topics/releases/0.9.5.rst b/doc/topics/releases/0.9.5.rst index 7864f8670aab..cee39d467f73 100644 --- a/doc/topics/releases/0.9.5.rst +++ b/doc/topics/releases/0.9.5.rst @@ -8,6 +8,11 @@ Salt 0.9.5 is one of the largest steps forward in the development of Salt. developers grow out to an international team of 46 code contributors and has many feature additions, feature enhancements, bug fixes and speed improvements. +.. warning:: + + Be sure to :ref:`read the upgrade instructions ` about the + switch to msgpack before upgrading! + Community ========= @@ -20,35 +25,35 @@ expandability of Salt is as exponential as I originally intended. commiters. The following individuals have contributed to the development of 0.9.5: -Aaron Bull Schaefer -Antti Kaihola -Bas Tichelaar -Brad Barden -Brian Wagner -Byron Clark -Chris Scheller -Christer Edwards -Clint Savage -Corey Quinn -David Boucha -Eivind Uggedal -Eric Poelke -Evan Borgstrom -Jed Glazner -Jeff Schroeder -Jeffrey C. Ollie -Jonas Buckner -Kent Tenney -Martin Schnabel -Maxim Burgerhout -Mitch Anderson -Nathaniel Whiteinge -Seth House -Thomas S Hatch -Thomas Schreiber -Tor Hveem -lzyeval -syphernl +* Aaron Bull Schaefer +* Antti Kaihola +* Bas Tichelaar +* Brad Barden +* Brian Wagner +* Byron Clark +* Chris Scheller +* Christer Edwards +* Clint Savage +* Corey Quinn +* David Boucha +* Eivind Uggedal +* Eric Poelke +* Evan Borgstrom +* Jed Glazner +* Jeff Schroeder +* Jeffrey C. Ollie +* Jonas Buckner +* Kent Tenney +* Martin Schnabel +* Maxim Burgerhout +* Mitch Anderson +* Nathaniel Whiteinge +* Seth House +* Thomas S Hatch +* Thomas Schreiber +* Tor Hveem +* lzyeval +* syphernl This makes 21 new developers since 0.9.4 was released! @@ -59,6 +64,8 @@ Salt on Github, and get coding (https://github.com/saltstack/salt)! Major Features ============== +.. _v0.9.5-msgpack: + SPEED! Pickle to msgpack ------------------------ @@ -75,20 +82,24 @@ This move introduces a few changes to Salt. First off, Salt is no longer a "noarch" package, since the msgpack lib is written in C. Salt 0.9.5 will also have compatibility issues with 0.9.4 with the default configuration. -We have gone through great lengths to avoid backwards compatibility issues -with Salt, but changing the serialization medium was going to create issues -regardless. Salt 0.9.5 is somewhat backwards compatible with earlier minions. -A 0.9.5 master can command older minions, but only if the ?serial? config -value in the master is set to ?pickle?. This will tell the master to publish -messages in pickle format and will allow the master to receive messages in -both msgpack and pickle formats. - -Therefore the suggested methods for upgrading are either to just upgrade -everything at once, or to upgrade the master to 0.9.5, set "serial: pickle" in -the master config, upgrade the minions, and then remove the serial option from -the config. Since pickles can be used as a security exploit the ability for a -master to accept pickles from minions at all will be removed in a future -release. +We have gone through great lengths to avoid backwards compatibility issues with +Salt, but changing the serialization medium was going to create issues +regardless. Salt 0.9.5 is somewhat backwards compatible with earlier minions. A +0.9.5 master can command older minions, but only if the :conf_master:`serial` +config value in the master is set to ``pickle``. This will tell the master to +publish messages in pickle format and will allow the master to receive messages +in both msgpack and pickle formats. + +Therefore **the suggested methods for upgrading** are either to just upgrade +everything at once, or: + +1. Upgrade the master to 0.9.5 +2. Set :conf_master:`serial` to ``pickle`` in the master config +3. Upgrade the minions +4. Remove the ``serial`` option from the master config + +Since pickles can be used as a security exploit the ability for a master to +accept pickles from minions at all will be removed in a future release. C Bindings for YAML -------------------- @@ -129,14 +140,15 @@ Modules via Module Environment Directories Under the file_roots each environment can now have directories that are used to deploy large groups of modules. These directories sync modules at the beginning of a state run on the minion, or can be manually synced via the Salt -module "saltutil.sync_all". +module :mod:`salt.modules.saltutil.sync_all`. The directories are named: -_modules -_states -_grains -_renderers -_returners + +* ``_modules`` +* ``_states`` +* ``_grains`` +* ``_renderers`` +* ``_returners`` The modules are pushed to their respective scopes on the minions. @@ -144,7 +156,7 @@ Module Reloading ---------------- Modules can now be reloaded without restarting the minion, this is done by -calling the sys.reload_modules function. +calling the :mod:`salt.modules.sys.reload_modules` function. But wait, there's more! Now when a salt module of any type is added via states the modules will be automatically reloaded, allowing for modules to be @@ -160,9 +172,9 @@ A great deal of demand has existed for adding the capability to set services to be started at boot in the service module. This feature also comes with an overhaul of the service modules and initial systemd support. -This means that the service state can now accept "- enable: True" to make sure -a service is enabled at boot, and "- enable: False" to make sure it is -disabled. +This means that the :mod:`service state ` can now +accept ``- enable: True`` to make sure a service is enabled at boot, and ``- +enable: False`` to make sure it is disabled. Compound Target --------------- @@ -172,12 +184,12 @@ previous versions the desired minions could only be targeted via a single specific target type, but now many target specifications can be declared. These targets can also be separated by and/or operators, so certain properties -can be used to omit a node: +can be used to omit a node:: -salt -C 'webserv* and G@os:Debian or E@db.*' test.ping + salt -C 'webserv* and G@os:Debian or E@db.*' test.ping will match all minions with ids starting with webserv via a glob and minions -matching the os:Debian grain. Or minions that match the "db.*" regular +matching the ``os:Debian`` grain. Or minions that match the ``db.*`` regular expression. @@ -187,15 +199,15 @@ Node Groups Often the convenience of having a predefined group of minions to execute targets on is desired. This can be accomplished with the new nodegroups feature. Nodegroups allow for predefined compound targets to be declared in -the master configuration file: +the master configuration file:: -nodegroups: - group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com' - group2: 'G@os:Debian and foo.domain.com' + nodegroups: + group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com' + group2: 'G@os:Debian and foo.domain.com' -And then used via the -N option: +And then used via the ``-N`` option:: -salt -N group1 test.ping + salt -N group1 test.ping Minion Side Data Store ----------------------- @@ -219,8 +231,8 @@ Salt -Q is Useful Now In the past the salt query system, which would display the data from recent executions would be displayed in pure python, and it was unreadable. -0.9.5 has added the outputter system to the -Q option, thus enabling the salt -query system to return readable output. +0.9.5 has added the outputter system to the ``-Q`` option, thus enabling the +salt query system to return readable output. Packaging Updates ================= @@ -255,9 +267,10 @@ Ubuntu and the package data that has been prepared is being pushed through the needed channels for inclusion. These packages have been prepared with the help of: -Corey -Aaron Toponce -and` + +* Corey +* Aaron Toponce +* and` More to Come ------------ @@ -291,67 +304,68 @@ This allows Salt to give much more granular error information. New Modules ----------- -data -```` +:mod:`data ` +``````````````````````````````` The new data module manages a persistent datastore on the minion. Big thanks to bastichelaar for his help refining this module -freebsdkmod -```````````` +:mod:`freebsdkmod ` +````````````````````````````````````````````` FreeBSD kernel modules can now be managed in the same way Salt handles Linux kernel modules. + This module was contributed thanks to the efforts of Christer Edwards -gentoo_service -`````````````` +:mod:`gentoo_service ` +``````````````````````````````````````````````````` Support has been added for managing services in Gentoo. Now Gentoo services can be started, stopped, restarted, enabled, disabled and viewed. -pip -```` +:mod:`pip ` +````````````````````````````` The pip module introduces management for pip installed applications. Thanks goes to whitinge for the addition of the pip module -rh_service -`````````` +:mod:`rh_service ` +``````````````````````````````````````````` The rh_service module enables Red Hat and Fedora specific service management. Now Red Hat like systems come with extensive management of the classic init system used by Red Hat -saltutil -```````` +:mod:`saltutil ` +``````````````````````````````````````` The saltutil module has been added as a place to hold functions used in the maintenance and management of salt itself. Saltutil is used to salt the salt minion. The saltutil module is presently used only to sync extension modules from the master server. -systemd -```````` +:mod:`systemd ` +````````````````````````````````````` Systemd support has been added to Salt, now systems using this next generation init system are supported on systems running systemd. -virtualenv -`````````` +:mod:`virtualenv ` +``````````````````````````````````````````` The virtualenv module has been added to allow salt to create virtual python environments. Thanks goes to whitinge for the addition of the virtualenv module -win_disk -```````` +:mod:`win_disk ` +``````````````````````````````````````` Support for gathering disk information on Microsoft Windows minions The windows modules come courtesy of Utah_Dave -win_service -``````````` +:mod:`win_service ` +````````````````````````````````````````````` The win_service module adds service support to Salt for Microsoft Windows services -win_useradd -```````````` +:mod:`win_useradd ` +````````````````````````````````````````````` Salt can now manage local users on Microsoft Windows Systems -yumpkg5 -``````` +:mod:`yumpkg5 ` +````````````````````````````````````` The yumpkg module introduces in 0.9.4 uses the yum api to interact with the yum package manager. Unfortunately, on Red Hat 5 systems salt does not have access to the yum api because the yum api is running under python 2.4 and Salt @@ -363,26 +377,27 @@ the yum api is not available. New States ----------- -mysql_database -`````````````` +:mod:`mysql_database ` +`````````````````````````````````````````````````` The new mysql_database state adds the ability to systems running a mysql server to manage the existence of mysql databases. The mysql states are thanks to syphernl -mysql_user -``````````` +:mod:`mysql_user ` +`````````````````````````````````````````` The mysql_user state enables mysql user management. -virtualenv -`````````` +:mod:`virtualenv ` +`````````````````````````````````````````` The virtualenv state can manage the state of python virtual environments. Thanks to Whitinge for the virtualenv state New Returners ------------- -cassandra_returner -`````````````````` +:mod:`cassandra_returner ` +``````````````````````````````````````````````````````````` + A returner allowing Salt to send data to a cassandra server. Thanks to Byron Clark for contributing this returner From 6c5e36f4a436d53686f69cfa64fbf834a7826e4e Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Mon, 16 Jan 2012 23:51:48 -0700 Subject: [PATCH 20/84] clean stray print statement --- salt/states/file.py | 1 - 1 file changed, 1 deletion(-) diff --git a/salt/states/file.py b/salt/states/file.py index 205ba8c566ea..0a8cb6944fd0 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -144,7 +144,6 @@ def _clean_dir(root, keep): if fn_ == '/': break rm_files = [] - print real_keep for roots, dirs, files in os.walk(root): for name in files: nfn = os.path.join(roots, name) From 1607550633438dc4b10c0c9eca9e9507d52d2c4e Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 00:58:00 -0700 Subject: [PATCH 21/84] Add source: {http,ftp} to the file.managed state --- salt/minion.py | 30 +++++++++++++++++++++--------- salt/states/file.py | 35 ++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index ce53e1071771..8f6d3583b269 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -567,7 +567,6 @@ def compound_match(self, tgt): if not matcher: # If an unknown matcher is called at any time, fail out return False - print comps results.append( str(getattr( self, @@ -582,7 +581,6 @@ def compound_match(self, tgt): )('@'.join(comps[1:])) )) - print ' '.join(results) return eval(' '.join(results)) class FileClient(object): @@ -695,14 +693,28 @@ def get_url(self, url, dest, makedirs=False, env='base'): ''' Get a single file from a URL. ''' - if urlparse.urlparse(url).scheme == 'salt': + url_data = urlparse.urlparse(url) + if url_data.scheme == 'salt': return self.get_file(url, dest, makedirs, env) - destdir = os.path.dirname(dest) - if not os.path.isdir(destdir): - if makedirs: + if dest: + destdir = os.path.dirname(dest) + if not os.path.isdir(destdir): + if makedirs: + os.makedirs(destdir) + else: + return False + else: + dest = os.path.join( + self.opts['cachedir'], + 'extrn_files', + env, + os.path.join( + url_data.netloc, + os.path.relpath(url_data.path, '/')) + ) + destdir = os.path.dirname(dest) + if not os.path.isdir(destdir): os.makedirs(destdir) - else: - return False try: with contextlib.closing(urllib2.urlopen(url)) as srcfp: with open(dest, 'wb') as destfp: @@ -722,7 +734,7 @@ def cache_file(self, path, env='base'): Pull a file down from the file server and store it in the minion file cache ''' - return self.get_file(path, '', True, env) + return self.get_url(path, '', True, env) def cache_files(self, paths, env='base'): ''' diff --git a/salt/states/file.py b/salt/states/file.py index 0a8cb6944fd0..73d2efb8e7dd 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -144,6 +144,7 @@ def _clean_dir(root, keep): if fn_ == '/': break rm_files = [] + print real_keep for roots, dirs, files in os.walk(root): for name in files: nfn = os.path.join(roots, name) @@ -428,26 +429,34 @@ def managed(name, source_sum = __salt__['cp.hash_file'](source, __env__) if not source_sum: ret['result'] = False - ret['comment'] = ('Checksum for source file {0} not' - ' found').format(source) + ret['comment'] = 'Source file {0} not found'.format(source) return ret - else: - # This file is not on a salt file server - sum_file = __salt__['cp.cache_file'](source_hash) - if not sum_file: + elif source_hash: + hash_fn = __salt__['cp.cache_file'](source_hash) + if not hash_fn: ret['result'] = False - ret['comment'] = ('Checksum for source file {0} not' - ' found').format(source) + ret['comment'] = 'Source hash file {0} not found'.format( + source_hash + ) return ret - comps = open(sum_source, 'r').read().split('=') + comps = open(hash_fn, 'r').read().split('=') if len(comps) < 2: ret['result'] = False - ret['comment'] = ('Checksum for source file {0} not' - ' formatted properly').format(source) + ret['comment'] = ('Source hash file {0} contains an ' + ' invalid hash format, it must be in ' + ' the format =').format( + source_hash + ) return ret - source_sum['hash_type'] = comps[0] source_sum['hsum'] = comps[1] - + source_sum['hash_type'] = comps[0] + else: + ret['result'] = False + ret['comment'] = ('Unable to determine upstream hash of' + ' source file {0}').format( + source + ) + return ret # If the source file is a template render it accordingly # Check changes if the target file exists From af5d17d18d5b83bda95ce83e34fbad28009f9422 Mon Sep 17 00:00:00 2001 From: Jeff Bauer Date: Tue, 17 Jan 2012 09:20:17 -0600 Subject: [PATCH 22/84] umask should permit user write permission (077) --- salt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/__init__.py b/salt/__init__.py index 909b430390b9..4b8dcafcfee9 100755 --- a/salt/__init__.py +++ b/salt/__init__.py @@ -26,7 +26,7 @@ def verify_env(dirs): for dir_ in dirs: if not os.path.isdir(dir_): try: - cumask = os.umask(191) + cumask = os.umask(63) # 077 os.makedirs(dir_) os.umask(cumask) except OSError, e: From f3e47d695c679069cc7c837ac90a657a4fd6d11e Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 09:41:50 -0800 Subject: [PATCH 23/84] More packaging fixups --- debian/control | 17 +++++++---------- salt/log.py | 0 salt/modules/apache.py | 0 salt/modules/mysql.py | 0 salt/modules/nginx.py | 0 5 files changed, 7 insertions(+), 10 deletions(-) mode change 100755 => 100644 salt/log.py mode change 100755 => 100644 salt/modules/apache.py mode change 100755 => 100644 salt/modules/mysql.py mode change 100755 => 100644 salt/modules/nginx.py diff --git a/debian/control b/debian/control index 7960077a9907..c1efa339a34c 100644 --- a/debian/control +++ b/debian/control @@ -57,10 +57,9 @@ Description: Shared libraries that salt requires for all packages Package: salt-master Architecture: all -Depends: ${python:Depends}, - ${misc:Depends}, +Depends: ${misc:Depends}, python (>= 2.6), - salt-common (= ${binary:Version}) + salt-common (= ${source:Version}) Description: This package provides a remote manager to administer servers via salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -81,10 +80,9 @@ Description: This package provides a remote manager to administer servers via sa Package: salt-minion Architecture: all -Depends: ${python:Depends}, - ${misc:Depends}, - python, - salt-common (= ${binary:Version}) +Depends: ${misc:Depends}, + python (>= 2.6), + salt-common (>= ${source:Version}) Description: This package represents the client package for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -105,10 +103,9 @@ Description: This package represents the client package for salt Package: salt-syndic Architecture: all -Depends: ${python:Depends}, - ${misc:Depends}, +Depends: ${misc:Depends}, python (>= 2.6), - salt-master + salt-master (>= ${source:Version}) Description: The syndic component represents the master-of-masters for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. diff --git a/salt/log.py b/salt/log.py old mode 100755 new mode 100644 diff --git a/salt/modules/apache.py b/salt/modules/apache.py old mode 100755 new mode 100644 diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py old mode 100755 new mode 100644 diff --git a/salt/modules/nginx.py b/salt/modules/nginx.py old mode 100755 new mode 100644 From af7690e0ebae1181268bb3ef770ef29added65ec Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 09:44:03 -0800 Subject: [PATCH 24/84] Fixed salt-common typo --- debian/control | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index c1efa339a34c..6091046e52c5 100644 --- a/debian/control +++ b/debian/control @@ -59,7 +59,7 @@ Package: salt-master Architecture: all Depends: ${misc:Depends}, python (>= 2.6), - salt-common (= ${source:Version}) + salt-common (>= ${source:Version}) Description: This package provides a remote manager to administer servers via salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -121,5 +121,5 @@ Description: The syndic component represents the master-of-masters for salt Between the remote execution system, and state management Salt addresses the backbone of cloud and data center management. . - This particular package provides the master of masters for salt-- it enables + This particular package provides the master of masters for salt-- it enables the management of multiple masters at a time. From 32503fec6d1d3942d6e3cad55aed0edec286305e Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 09:53:17 -0800 Subject: [PATCH 25/84] Fixed wildcarding in install files --- debian/salt-common.install | 11 ++++++++++- debian/salt-minion.install | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/debian/salt-common.install b/debian/salt-common.install index 037a3fb7c9dd..dd3768065b25 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -5,4 +5,13 @@ usr/share/man/man1/salt-master.1 usr/share/man/man1/salt-syndic.1 usr/share/man/man1/salt-cp.1 usr/share/man/man1/salt.1 -salt/* /usr/share/salt/ +salt/ /usr/share/salt/ +salt/runners /usr/share/salt/runners +salt/renderers /usr/share/salt/renderers +salt/returners /usr/share/salt/returners +salt/ext /usr/share/salt/ext +salt/msgpack /usr/share/salt/msgpack +salt/grains /usr/share/salt/grains +salt/cli /usr/share/salt/cli +salt/states /usr/share/salt/states +salt/utils /usr/share/salt/utils diff --git a/debian/salt-minion.install b/debian/salt-minion.install index d882649e286b..0cabe00dd1a1 100644 --- a/debian/salt-minion.install +++ b/debian/salt-minion.install @@ -1,4 +1,4 @@ scripts/salt-minion /usr/share/salt/salt-minion scripts/salt-call /usr/share/salt/salt-call -salt/modules/* /usr/share/salt/modules/ +salt/modules/ /usr/share/salt/modules/ conf/minion.template /etc/salt/minion From 24e05771df9646af1abf263ece3e3fc88f1d0539 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 09:57:31 -0800 Subject: [PATCH 26/84] Removed extra man pages --- debian/salt-master.manpages | 6 ------ debian/salt-minion.manpages | 2 -- debian/salt-syndic.manpages | 1 - 3 files changed, 9 deletions(-) delete mode 100644 debian/salt-master.manpages delete mode 100644 debian/salt-minion.manpages delete mode 100644 debian/salt-syndic.manpages diff --git a/debian/salt-master.manpages b/debian/salt-master.manpages deleted file mode 100644 index 074f304fb2c4..000000000000 --- a/debian/salt-master.manpages +++ /dev/null @@ -1,6 +0,0 @@ -doc/man/salt.7 -doc/man/salt.1 -doc/man/salt-master.1 -doc/man/salt-key.1 -doc/man/salt-cp.1 -doc/man/salt-run.1 diff --git a/debian/salt-minion.manpages b/debian/salt-minion.manpages deleted file mode 100644 index d8d924f31a95..000000000000 --- a/debian/salt-minion.manpages +++ /dev/null @@ -1,2 +0,0 @@ -doc/man/salt-call.1 -doc/man/salt-minion.1 diff --git a/debian/salt-syndic.manpages b/debian/salt-syndic.manpages deleted file mode 100644 index 09238dc4e1a8..000000000000 --- a/debian/salt-syndic.manpages +++ /dev/null @@ -1 +0,0 @@ -doc/man/salt-syndic.1 From 2fcc37670b5a9b0618843e71facd60ee0ea50cbe Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 09:59:31 -0800 Subject: [PATCH 27/84] Removed trailing slash --- debian/salt-common.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/salt-common.install b/debian/salt-common.install index dd3768065b25..c12c810c14c9 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -5,7 +5,7 @@ usr/share/man/man1/salt-master.1 usr/share/man/man1/salt-syndic.1 usr/share/man/man1/salt-cp.1 usr/share/man/man1/salt.1 -salt/ /usr/share/salt/ +salt/ /usr/share/salt salt/runners /usr/share/salt/runners salt/renderers /usr/share/salt/renderers salt/returners /usr/share/salt/returners From 8a06d69f36f2fd438418f8276bd1513dab3dba7f Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 10:14:56 -0800 Subject: [PATCH 28/84] Fixed links --- debian/salt-common.install | 1 + debian/{links => salt-master.links} | 2 -- debian/salt-minion.links | 2 ++ debian/salt-syndic.links | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) rename debian/{links => salt-master.links} (72%) create mode 100644 debian/salt-minion.links create mode 100644 debian/salt-syndic.links diff --git a/debian/salt-common.install b/debian/salt-common.install index c12c810c14c9..391fb96db84c 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -15,3 +15,4 @@ salt/grains /usr/share/salt/grains salt/cli /usr/share/salt/cli salt/states /usr/share/salt/states salt/utils /usr/share/salt/utils +scripts /usr/share/salt diff --git a/debian/links b/debian/salt-master.links similarity index 72% rename from debian/links rename to debian/salt-master.links index e325b02fa1d7..77e00bad80f7 100644 --- a/debian/links +++ b/debian/salt-master.links @@ -1,8 +1,6 @@ usr/share/salt/salt /usr/bin/salt usr/share/salt/salt-master /usr/bin/salt-master -usr/share/salt/salt-syndic /usr/bin/salt-syndic usr/share/salt/salt-cp /usr/bin/salt-cp usr/share/salt/salt-key /usr/bin/salt-key usr/share/salt/salt-run /usr/bin/salt-run -usr/share/salt/salt-minion /usr/bin/salt-minion usr/share/salt/salt-call /usr/bin/salt-call diff --git a/debian/salt-minion.links b/debian/salt-minion.links new file mode 100644 index 000000000000..599cef31fd49 --- /dev/null +++ b/debian/salt-minion.links @@ -0,0 +1,2 @@ +usr/share/salt/salt-minion /usr/bin/salt-minion +usr/share/salt/salt-call /usr/bin/salt-call diff --git a/debian/salt-syndic.links b/debian/salt-syndic.links new file mode 100644 index 000000000000..3edb1ec97d7d --- /dev/null +++ b/debian/salt-syndic.links @@ -0,0 +1 @@ +usr/share/salt/salt-syndic /usr/bin/salt-syndic From 019620d891bb0f19c49c4b78eeec8dcd10eb2ef0 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 10:25:10 -0800 Subject: [PATCH 29/84] Moved binaries to proper packages --- debian/salt-common.install | 1 - debian/salt-master.install | 5 +++++ debian/salt-syndic.install | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/salt-common.install b/debian/salt-common.install index 391fb96db84c..c12c810c14c9 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -15,4 +15,3 @@ salt/grains /usr/share/salt/grains salt/cli /usr/share/salt/cli salt/states /usr/share/salt/states salt/utils /usr/share/salt/utils -scripts /usr/share/salt diff --git a/debian/salt-master.install b/debian/salt-master.install index 9d418d39bd66..80e93e1cacb6 100644 --- a/debian/salt-master.install +++ b/debian/salt-master.install @@ -1 +1,6 @@ conf/master.template /etc/salt/master +scripts/salt-key /usr/share/salt +scripts/salt /usr/share/salt +scripts/salt-run /usr/share/salt +scripts/salt-cp /usr/share/salt +scripts/salt-master /usr/share/salt diff --git a/debian/salt-syndic.install b/debian/salt-syndic.install index e69de29bb2d1..e4bc32428113 100644 --- a/debian/salt-syndic.install +++ b/debian/salt-syndic.install @@ -0,0 +1 @@ +scripts/salt-syndic /usr/share/salt From 2aa0521d47bb4cc943bd62d3d7442c90fa52cf48 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 10:33:16 -0800 Subject: [PATCH 30/84] Fixed man pages --- debian/salt-common.manpages | 8 -------- debian/salt-master.manpages | 5 +++++ debian/salt-minion.manpages | 2 ++ 3 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 debian/salt-master.manpages create mode 100644 debian/salt-minion.manpages diff --git a/debian/salt-common.manpages b/debian/salt-common.manpages index 43d8412c8da2..ce2ea1742d68 100644 --- a/debian/salt-common.manpages +++ b/debian/salt-common.manpages @@ -1,9 +1 @@ -doc/man/salt.1 doc/man/salt.7 -doc/man/salt-call.1 -doc/man/salt-cp.1 -doc/man/salt-key.1 -doc/man/salt-master.1 -doc/man/salt-minion.1 -doc/man/salt-run.1 -doc/man/salt-syndic.1 diff --git a/debian/salt-master.manpages b/debian/salt-master.manpages new file mode 100644 index 000000000000..52beb2836be5 --- /dev/null +++ b/debian/salt-master.manpages @@ -0,0 +1,5 @@ +doc/man/salt.1 +doc/man/salt-cp.1 +doc/man/salt-key.1 +doc/man/salt-master.1 +doc/man/salt-run.1 diff --git a/debian/salt-minion.manpages b/debian/salt-minion.manpages new file mode 100644 index 000000000000..d8d924f31a95 --- /dev/null +++ b/debian/salt-minion.manpages @@ -0,0 +1,2 @@ +doc/man/salt-call.1 +doc/man/salt-minion.1 From d275669b5b03febf7e2f09c6ca68bdd8f642d144 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 11:00:04 -0800 Subject: [PATCH 31/84] Pathing --- debian/salt-common.install | 26 +++++++++----------------- debian/salt-master.links | 1 - debian/salt-minion.install | 6 +++--- debian/salt-syndic.manpages | 1 + salt/__init__.py | 0 salt/utils/find.py | 0 6 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 debian/salt-syndic.manpages mode change 100755 => 100644 salt/__init__.py mode change 100755 => 100644 salt/utils/find.py diff --git a/debian/salt-common.install b/debian/salt-common.install index c12c810c14c9..236eb94a4f09 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -1,17 +1,9 @@ -usr/share/man/man1/salt-minion.1 -usr/share/man/man1/salt-call.1 -usr/share/man/man1/salt-key.1 -usr/share/man/man1/salt-master.1 -usr/share/man/man1/salt-syndic.1 -usr/share/man/man1/salt-cp.1 -usr/share/man/man1/salt.1 -salt/ /usr/share/salt -salt/runners /usr/share/salt/runners -salt/renderers /usr/share/salt/renderers -salt/returners /usr/share/salt/returners -salt/ext /usr/share/salt/ext -salt/msgpack /usr/share/salt/msgpack -salt/grains /usr/share/salt/grains -salt/cli /usr/share/salt/cli -salt/states /usr/share/salt/states -salt/utils /usr/share/salt/utils +salt/runners /usr/share/salt/ +salt/renderers /usr/share/salt/ +salt/returners /usr/share/salt/ +salt/ext /usr/share/salt/ +salt/msgpack /usr/share/salt/ +salt/grains /usr/share/salt/ +salt/cli /usr/share/salt/ +salt/states /usr/share/salt/ +salt/utils /usr/share/salt/ diff --git a/debian/salt-master.links b/debian/salt-master.links index 77e00bad80f7..0b3afffea41c 100644 --- a/debian/salt-master.links +++ b/debian/salt-master.links @@ -3,4 +3,3 @@ usr/share/salt/salt-master /usr/bin/salt-master usr/share/salt/salt-cp /usr/bin/salt-cp usr/share/salt/salt-key /usr/bin/salt-key usr/share/salt/salt-run /usr/bin/salt-run -usr/share/salt/salt-call /usr/bin/salt-call diff --git a/debian/salt-minion.install b/debian/salt-minion.install index 0cabe00dd1a1..03f11693026b 100644 --- a/debian/salt-minion.install +++ b/debian/salt-minion.install @@ -1,4 +1,4 @@ -scripts/salt-minion /usr/share/salt/salt-minion -scripts/salt-call /usr/share/salt/salt-call -salt/modules/ /usr/share/salt/modules/ +scripts/salt-minion /usr/share/salt +scripts/salt-call /usr/share/salt +salt/modules /usr/share/salt/modules conf/minion.template /etc/salt/minion diff --git a/debian/salt-syndic.manpages b/debian/salt-syndic.manpages new file mode 100644 index 000000000000..09238dc4e1a8 --- /dev/null +++ b/debian/salt-syndic.manpages @@ -0,0 +1 @@ +doc/man/salt-syndic.1 diff --git a/salt/__init__.py b/salt/__init__.py old mode 100755 new mode 100644 diff --git a/salt/utils/find.py b/salt/utils/find.py old mode 100755 new mode 100644 From 774451951b4f91e2a954aca497d18b56ae7e336e Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 11:03:37 -0800 Subject: [PATCH 32/84] Perms tweak --- salt/states/mysql_database.py | 0 salt/states/mysql_user.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 salt/states/mysql_database.py mode change 100755 => 100644 salt/states/mysql_user.py diff --git a/salt/states/mysql_database.py b/salt/states/mysql_database.py old mode 100755 new mode 100644 diff --git a/salt/states/mysql_user.py b/salt/states/mysql_user.py old mode 100755 new mode 100644 From f32c78605b65f33e4dc4fef519ca1bf8f7f94266 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 11:07:44 -0800 Subject: [PATCH 33/84] Missing files --- debian/salt-common.install | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/debian/salt-common.install b/debian/salt-common.install index 236eb94a4f09..1c847b7b1e4c 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -1,3 +1,17 @@ +salt/exceptions.py /usr/share/salt +salt/loader.py /usr/share/salt +salt/master.py /usr/share/salt +salt/client.py /usr/share/salt +salt/runner.py /usr/share/salt +salt/output.py /usr/share/salt +salt/minion.py /usr/share/salt +salt/version.py /usr/share/salt +salt/config.py /usr/share/salt +salt/state.py /usr/share/salt +salt/log.py /usr/share/salt +salt/__init__.py /usr/share/salt +salt/payload.py /usr/share/salt +salt/crypt.py /usr/share/salt salt/runners /usr/share/salt/ salt/renderers /usr/share/salt/ salt/returners /usr/share/salt/ From f075dfc7af964c5bed66a9dc0ed709f86514526f Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 11:17:21 -0800 Subject: [PATCH 34/84] Fixed spacing --- debian/control | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/debian/control b/debian/control index 6091046e52c5..aa794c2ad610 100644 --- a/debian/control +++ b/debian/control @@ -23,20 +23,20 @@ Homepage: http://saltstack.org Package: salt-common Architecture: any -Depends: ${python:Depends}, - ${misc:Depends}, - python-support, - cython, - python-yaml, - python-setuptools, - python-yaml, - python-crypto, - python-m2crypto, - python-zmq (>= 2.1.9), - libzmq-dev (>= 2.1.9), - python (>= 2.6), - python-dev (>= 2.6), - python-jinja2 +Depends: ${python:Depends}, + ${misc:Depends}, + python-support, + cython, + python-yaml, + python-setuptools, + python-yaml, + python-crypto, + python-m2crypto, + python-zmq (>= 2.1.9), + libzmq-dev (>= 2.1.9), + python (>= 2.6), + python-dev (>= 2.6), + python-jinja2 Description: Shared libraries that salt requires for all packages This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -57,9 +57,9 @@ Description: Shared libraries that salt requires for all packages Package: salt-master Architecture: all -Depends: ${misc:Depends}, - python (>= 2.6), - salt-common (>= ${source:Version}) +Depends: ${misc:Depends}, + python (>= 2.6), + salt-common (>= ${source:Version}) Description: This package provides a remote manager to administer servers via salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -80,9 +80,9 @@ Description: This package provides a remote manager to administer servers via sa Package: salt-minion Architecture: all -Depends: ${misc:Depends}, - python (>= 2.6), - salt-common (>= ${source:Version}) +Depends: ${misc:Depends}, + python (>= 2.6), + salt-common (>= ${source:Version}) Description: This package represents the client package for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -103,9 +103,9 @@ Description: This package represents the client package for salt Package: salt-syndic Architecture: all -Depends: ${misc:Depends}, - python (>= 2.6), - salt-master (>= ${source:Version}) +Depends: ${misc:Depends}, + python (>= 2.6), + salt-master (>= ${source:Version}) Description: The syndic component represents the master-of-masters for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. From c3b65e186bd780f8dbec2bd6c6a49c29f3445797 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 11:20:08 -0800 Subject: [PATCH 35/84] Fixed another lintian error --- debian/control | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/debian/control b/debian/control index aa794c2ad610..f522ea2d80ac 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,6 @@ Build-Depends: debhelper (>= 7.0.50~), cython, python-yaml, python-setuptools, - python-yaml, python-crypto, python-m2crypto, python-zmq (>= 2.1.9), @@ -27,7 +26,6 @@ Depends: ${python:Depends}, ${misc:Depends}, python-support, cython, - python-yaml, python-setuptools, python-yaml, python-crypto, @@ -106,7 +104,7 @@ Architecture: all Depends: ${misc:Depends}, python (>= 2.6), salt-master (>= ${source:Version}) -Description: The syndic component represents the master-of-masters for salt +Description: This package represents the master-of-masters for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. . From da59653fbb6184a633afc91815030ba35ad39bf9 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 11:48:05 -0800 Subject: [PATCH 36/84] build the msgpack stuff --- debian/rules | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index a140040585e6..5bde0a66badf 100755 --- a/debian/rules +++ b/debian/rules @@ -2,7 +2,10 @@ %: dh $@ - +override_dh_auto_build: + python setup.py build +override_dh_auto_install: + python setup.py install #override_dh_installinit: # dh_installinit --no-start --name="salt-master" # dh_installinit --no-start --name="salt-minion" From b8b427ecc916b71e54e38cbae2497ba7c08b6cc3 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 12:48:26 -0800 Subject: [PATCH 37/84] Updating rules and install files --- debian/control | 4 ++-- debian/rules | 8 ++------ debian/salt-common.install | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/debian/control b/debian/control index f522ea2d80ac..17c7e48937b0 100644 --- a/debian/control +++ b/debian/control @@ -11,8 +11,7 @@ Build-Depends: debhelper (>= 7.0.50~), python-m2crypto, python-zmq (>= 2.1.9), libzmq-dev (>= 2.1.9), - python (>= 2.6), - python-dev (>= 2.6), + python-all-dev, python-jinja2 Standards-Version: 3.9.2 Homepage: http://saltstack.org @@ -24,6 +23,7 @@ Package: salt-common Architecture: any Depends: ${python:Depends}, ${misc:Depends}, + ${shlibs:Depends}, python-support, cython, python-setuptools, diff --git a/debian/rules b/debian/rules index 5bde0a66badf..04dfdf8f2887 100755 --- a/debian/rules +++ b/debian/rules @@ -1,11 +1,7 @@ #!/usr/bin/make -f - +#export DH_VERBOSE=1 %: - dh $@ -override_dh_auto_build: - python setup.py build -override_dh_auto_install: - python setup.py install + dh $@ --buildsystem=python_distutils #override_dh_installinit: # dh_installinit --no-start --name="salt-master" # dh_installinit --no-start --name="salt-minion" diff --git a/debian/salt-common.install b/debian/salt-common.install index 1c847b7b1e4c..06237cb262af 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -21,3 +21,4 @@ salt/grains /usr/share/salt/ salt/cli /usr/share/salt/ salt/states /usr/share/salt/ salt/utils /usr/share/salt/ +usr/lib/python2*/dist-packages/salt/msgpack From 078103a4b1b0c7eaa15b227b6526b5b89e5eb9a0 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 15:21:26 -0800 Subject: [PATCH 38/84] Fixed shebang --- scripts/salt | 2 +- scripts/salt-call | 2 +- scripts/salt-cp | 2 +- scripts/salt-key | 2 +- scripts/salt-master | 2 +- scripts/salt-minion | 2 +- scripts/salt-run | 2 +- scripts/salt-syndic | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/salt b/scripts/salt index 2c245c83f4cd..d38782886494 100755 --- a/scripts/salt +++ b/scripts/salt @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Publish commands to the salt system from the command line on the master. ''' diff --git a/scripts/salt-call b/scripts/salt-call index b2f3585b5bd7..0cee11d2f682 100755 --- a/scripts/salt-call +++ b/scripts/salt-call @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Directly call a salt command in the modules, does not require a running salt minion to run. diff --git a/scripts/salt-cp b/scripts/salt-cp index b38151d953cf..e3a1fa426e70 100755 --- a/scripts/salt-cp +++ b/scripts/salt-cp @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Publish commands to the salt system from the command line on the master. ''' diff --git a/scripts/salt-key b/scripts/salt-key index 0a0fec5112dc..e8a91d571aee 100755 --- a/scripts/salt-key +++ b/scripts/salt-key @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Manage the authentication keys with salt-key ''' diff --git a/scripts/salt-master b/scripts/salt-master index e409281e5cef..96e586685f24 100755 --- a/scripts/salt-master +++ b/scripts/salt-master @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Start the salt-master ''' diff --git a/scripts/salt-minion b/scripts/salt-minion index f6745445582b..d9e0782559f0 100755 --- a/scripts/salt-minion +++ b/scripts/salt-minion @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python ''' This script is used to kick off a salt minion daemon ''' diff --git a/scripts/salt-run b/scripts/salt-run index e5e996c96f32..0c933690065f 100755 --- a/scripts/salt-run +++ b/scripts/salt-run @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Execute a salt convenience routine ''' diff --git a/scripts/salt-syndic b/scripts/salt-syndic index b122993bfac9..5a46a52c450e 100755 --- a/scripts/salt-syndic +++ b/scripts/salt-syndic @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python ''' This script is used to kick off a salt syndic daemon ''' From 82c7afe3641a99cfa29e43a10fe53a2801ccf7b0 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Tue, 17 Jan 2012 15:32:43 -0800 Subject: [PATCH 39/84] Control updates --- debian/control | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/debian/control b/debian/control index 17c7e48937b0..6ba30ed2e248 100644 --- a/debian/control +++ b/debian/control @@ -32,8 +32,8 @@ Depends: ${python:Depends}, python-m2crypto, python-zmq (>= 2.1.9), libzmq-dev (>= 2.1.9), - python (>= 2.6), - python-dev (>= 2.6), + python, + python-dev, python-jinja2 Description: Shared libraries that salt requires for all packages This package is a powerful remote execution manager that can be used @@ -56,7 +56,7 @@ Description: Shared libraries that salt requires for all packages Package: salt-master Architecture: all Depends: ${misc:Depends}, - python (>= 2.6), + python, salt-common (>= ${source:Version}) Description: This package provides a remote manager to administer servers via salt This package is a powerful remote execution manager that can be used @@ -79,7 +79,7 @@ Description: This package provides a remote manager to administer servers via sa Package: salt-minion Architecture: all Depends: ${misc:Depends}, - python (>= 2.6), + python, salt-common (>= ${source:Version}) Description: This package represents the client package for salt This package is a powerful remote execution manager that can be used @@ -102,7 +102,7 @@ Description: This package represents the client package for salt Package: salt-syndic Architecture: all Depends: ${misc:Depends}, - python (>= 2.6), + python, salt-master (>= ${source:Version}) Description: This package represents the master-of-masters for salt This package is a powerful remote execution manager that can be used From 348fa2ee6f41e15b2e0b937dd3c4bef3f387207e Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 21:05:56 -0700 Subject: [PATCH 40/84] cmd.retcode no longer uses subprocess.call since it is broken --- salt/modules/cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/cmd.py b/salt/modules/cmd.py index 4586386d50f0..c49cea564680 100644 --- a/salt/modules/cmd.py +++ b/salt/modules/cmd.py @@ -123,7 +123,7 @@ def retcode(cmd, cwd=DEFAULT_CWD): salt '*' cmd.retcode "file /bin/bash" ''' log.info('Executing command {0} in directory {1}'.format(cmd, cwd)) - return subprocess.call(cmd, shell=True, cwd=cwd) + return _run(cmd, cwd=cwd)['retcode'] def has_exec(cmd): From baf3e6a3594645c92509dba4ede68c28b765df37 Mon Sep 17 00:00:00 2001 From: Evan Borgstrom Date: Tue, 17 Jan 2012 23:07:40 -0500 Subject: [PATCH 41/84] Bye-bye pickle, hello msgpack --- doc/topics/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/topics/index.rst b/doc/topics/index.rst index 756b16c7ceac..7340c3fb8904 100644 --- a/doc/topics/index.rst +++ b/doc/topics/index.rst @@ -45,9 +45,10 @@ contains a viable, and transparent, AMQ broker inside the daemon. Salt uses public keys for authentication with the master daemon, then uses faster AES encryption for payload communication, this means that authentication and encryption are also built into Salt. Salt takes advantage of communication via -Python pickles, enabling fast and light network traffic. +`msgpack`_, enabling fast and light network traffic. .. _`ZeroMQ`: http://www.zeromq.org/ +.. _`msgpack`: http://msgpack.org/ Python client interface ======================= From 67350940b29cf7f5168b3b777c34432bf15daa7b Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 21:27:18 -0700 Subject: [PATCH 42/84] fix issue with source_hash and trailing whitespace --- salt/states/file.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index 73d2efb8e7dd..1c156963c470 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -448,8 +448,8 @@ def managed(name, source_hash ) return ret - source_sum['hsum'] = comps[1] - source_sum['hash_type'] = comps[0] + source_sum['hsum'] = comps[1].strip() + source_sum['hash_type'] = comps[0].strip() else: ret['result'] = False ret['comment'] = ('Unable to determine upstream hash of' From 12791e69a7522889095420488637ce323c9de19d Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 21:43:04 -0700 Subject: [PATCH 43/84] Add docs for new source powers --- salt/states/file.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index 1c156963c470..0686c844a40f 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -345,11 +345,21 @@ def managed(name, The location of the file to manage source - The source file, this file is located on the salt master file server - and is specified with the salt:// protocol. If the file is located on + The source file to download to the minion, this source file can be + hosted on either the salt master server, or on an http or ftp server. + For files hosted on the salt file server, if the file is located on the master in the directory named spam, and is called eggs, the source string is salt://spam/eggs. If source is left blank or None, the file - will be created as an empty file and the content will not be managed + will be created as an empty file and the content will not be managed + + If the file is hosted on a http or ftp server then the source_hash + argument is also required + + source_hash: + This can be either a file which contains a source hash string for + the source, or a source hash string. The source hash string is the + hash algorithm followed by the hash of the file: + md5=e138491e9d5b97023cea823fe17bac22 user The user to own the file, this defaults to the user salt is running as From 8767338eb5900c52c0052ae89198c13e554d0f58 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 21:52:15 -0700 Subject: [PATCH 44/84] Add support for source_hash to be a source hash string --- salt/states/file.py | 52 +++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index 0686c844a40f..89da1ba74f0c 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -442,24 +442,40 @@ def managed(name, ret['comment'] = 'Source file {0} not found'.format(source) return ret elif source_hash: - hash_fn = __salt__['cp.cache_file'](source_hash) - if not hash_fn: - ret['result'] = False - ret['comment'] = 'Source hash file {0} not found'.format( - source_hash - ) - return ret - comps = open(hash_fn, 'r').read().split('=') - if len(comps) < 2: - ret['result'] = False - ret['comment'] = ('Source hash file {0} contains an ' - ' invalid hash format, it must be in ' - ' the format =').format( - source_hash - ) - return ret - source_sum['hsum'] = comps[1].strip() - source_sum['hash_type'] = comps[0].strip() + protos = ['salt', 'http', 'ftp'] + if urlparse.urlparse(source_hash).scheme in protos: + # The sourc_hash is a file on a server + hash_fn = __salt__['cp.cache_file'](source_hash) + if not hash_fn: + ret['result'] = False + ret['comment'] = 'Source hash file {0} not found'.format( + source_hash + ) + return ret + comps = open(hash_fn, 'r').read().split('=') + if len(comps) < 2: + ret['result'] = False + ret['comment'] = ('Source hash file {0} contains an ' + ' invalid hash format, it must be in ' + ' the format =').format( + source_hash + ) + return ret + source_sum['hsum'] = comps[1].strip() + source_sum['hash_type'] = comps[0].strip() + else: + # The source_hash is a hash string + comps = source_hash.split('=') + if len(comps) < 2: + ret['result'] = False + ret['comment'] = ('Source hash file {0} contains an ' + ' invalid hash format, it must be in ' + ' the format =').format( + source_hash + ) + return ret + source_sum['hsum'] = comps[1].strip() + source_sum['hash_type'] = comps[0].strip() else: ret['result'] = False ret['comment'] = ('Unable to determine upstream hash of' From dc2ab217140e4eaf1cf2d44ed8429f827466c6d7 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 22:28:21 -0700 Subject: [PATCH 45/84] add pure python template type --- salt/states/file.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/salt/states/file.py b/salt/states/file.py index 89da1ba74f0c..b7c92ef3636c 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -69,6 +69,7 @@ import shutil import difflib import hashlib +import imp import logging import tempfile import traceback @@ -223,6 +224,43 @@ def _jinja(sfn, name, source, user, group, mode, env, context=None): 'data': trb} +def _py(sfn, name, source, user, group, mode, env, context=None): + ''' + Render a template from a python source file + + Returns:: + + {'result': bool, + 'data': } + ''' + if not os.path.isfile(sfn): + return {} + + mod = imp.load_source( + os.path.basename(sfn).split('.')[0], + sfn + ) + mod.salt = __salt__ + mod.grains = __grains__ + mod.name = name + mod.source = source + mod.user = user + mod.group = group + mod.mode = mode + mod.env = env + mod.context = context + + try: + tgt = tempfile.mkstemp()[1] + open(tgt, 'w+').write(mod.run()) + return {'result': True, + 'data': tgt} + except: + trb = traceback.format_exc() + return {'result': False, + 'data': trb} + + def symlink(name, target, force=False, makedirs=False): ''' Create a symlink From f5dd9ce2343daaae384cf4444f9afe3455aad303 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 22:46:21 -0700 Subject: [PATCH 46/84] add return clarifying that no states were found if no states are found --- salt/state.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/salt/state.py b/salt/state.py index c3a2f85e6f60..f588e96df5c7 100644 --- a/salt/state.py +++ b/salt/state.py @@ -989,6 +989,14 @@ def call_highstate(self): high, errors = self.render_highstate(matches) if errors: return errors + if not high: + return {'no.states': { + 'result': False, + 'comment': 'No states found for this minion', + 'name': 'No States', + 'changes': {} + } + } return self.state.call_high(high) def compile_highstate(self): From f63a38d025166d4fa7a55ca3aed74e0bafeafe64 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 23:26:39 -0700 Subject: [PATCH 47/84] change some strings to use format --- salt/minion.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 8f6d3583b269..2eca44260ccd 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -231,7 +231,12 @@ def _thread_return(self, data): try: self.returners[data['ret']](ret) except Exception as exc: - log.error('The return failed for job %s %s', data['jid'], exc) + log.error( + 'The return failed for job {0} {1}'.format( + data['jid'], + exc + ) + ) else: self._return_pub(ret) @@ -259,7 +264,11 @@ def _thread_multi_return(self, data): = self.functions[data['fun'][ind]](*data['arg'][ind]) except Exception as exc: trb = traceback.format_exc() - log.warning('The minion function caused an exception: %s', exc) + log.warning( + 'The minion function caused an exception: {0}'.format( + exc + ) + ) ret['return'][data['fun'][ind]] = trb ret['jid'] = data['jid'] if data['ret']: @@ -267,7 +276,9 @@ def _thread_multi_return(self, data): try: self.returners[data['ret']](ret) except Exception as exc: - log.error('The return failed for job %s %s', data['jid'], exc) + log.error('The return failed for job {0} {1}'.format( + data['jid'], exc + )) else: self._return_pub(ret) @@ -275,7 +286,7 @@ def _return_pub(self, ret, ret_cmd='_return'): ''' Return the data from the executed command to the master server ''' - log.info('Returning information for job: %(jid)s', ret) + log.info('Returning information for job: {0}'.format(ret['jid'])) context = zmq.Context() socket = context.socket(zmq.REQ) socket.connect(self.opts['master_uri']) From b2151521bb19e0571d822e38fce592dc70b940cf Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 23:45:42 -0700 Subject: [PATCH 48/84] add code to cache jobs on the minion if option is set --- salt/config.py | 1 + salt/minion.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/salt/config.py b/salt/config.py index 5863c444ca9a..641605980faa 100644 --- a/salt/config.py +++ b/salt/config.py @@ -80,6 +80,7 @@ def minion_config(path): 'pki_dir': '/etc/salt/pki', 'id': socket.getfqdn(), 'cachedir': '/var/cache/salt', + 'cache_jobs': False, 'conf_file': path, 'renderer': 'yaml_jinja', 'failhard': False, diff --git a/salt/minion.py b/salt/minion.py index 2eca44260ccd..1257817f6e9a 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -312,8 +312,21 @@ def _return_pub(self, ret, ret_cmd='_return'): except KeyError: pass payload['load'] = self.crypticle.dumps(load) - socket.send(self.serial.dumps(payload)) - return socket.recv() + data = self.serial.dumps(payload) + socket.send(data) + ret = socket.recv() + if self.opts['cache_jobs']: + # Local job cache has been enabled + fn_ = os.path.join( + self.opts['cachedir'], + 'minion_jobs', + load['jid'], + 'return.p') + jdir = os.path.dirname(fn_) + if not os.path.isdir(jdir): + os.makedirs(jdir) + open(fn_, 'w+').write(load) + return ret def authenticate(self): ''' From d925e4f5ced652684f7cbb7043628e79f424b364 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 23:49:57 -0700 Subject: [PATCH 49/84] serialize cache data --- salt/minion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/minion.py b/salt/minion.py index 1257817f6e9a..8d8de17bbc3d 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -325,7 +325,7 @@ def _return_pub(self, ret, ret_cmd='_return'): jdir = os.path.dirname(fn_) if not os.path.isdir(jdir): os.makedirs(jdir) - open(fn_, 'w+').write(load) + self.serial.dump(load, fn_) return ret def authenticate(self): From 1e13d5b12e10e91fbb1caac19ee8f939cf12f1bd Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 23:56:45 -0700 Subject: [PATCH 50/84] was caching the wrong line data --- salt/minion.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 8d8de17bbc3d..08cb0754116e 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -314,7 +314,7 @@ def _return_pub(self, ret, ret_cmd='_return'): payload['load'] = self.crypticle.dumps(load) data = self.serial.dumps(payload) socket.send(data) - ret = socket.recv() + ret_val = socket.recv() if self.opts['cache_jobs']: # Local job cache has been enabled fn_ = os.path.join( @@ -325,8 +325,8 @@ def _return_pub(self, ret, ret_cmd='_return'): jdir = os.path.dirname(fn_) if not os.path.isdir(jdir): os.makedirs(jdir) - self.serial.dump(load, fn_) - return ret + open(fn_, 'w+').write(self.serial.dumps(ret)) + return ret_val def authenticate(self): ''' From 302857aca09662a71ed0239f501957a727fa4b19 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 17 Jan 2012 23:59:01 -0700 Subject: [PATCH 51/84] Add cache_jobs to the minion config template --- conf/minion.template | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/conf/minion.template b/conf/minion.template index 669ff76f6c12..3d739a4998e0 100644 --- a/conf/minion.template +++ b/conf/minion.template @@ -29,10 +29,16 @@ # Where cache data goes #cachedir: /var/cache/salt +# The minion can locally cache the return data from jobs sent to it, this +# can be a good way to keep track minion side of the jobs the minion has +# executed. By default this feature is disabled, to enable set cache_jobs +# to True +#cache_jobs: False + # When waiting for a master to accept the minion's public key, salt will -# contiuously attempt to reconnect until successful. This is the time, in +# continuously attempt to reconnect until successful. This is the time, in # seconds, between those reconnection attempts. -# acceptance_wait_time = 10 +#acceptance_wait_time = 10 From f89e89d85038ac7d4b12dc6276f45880fef74acb Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Wed, 18 Jan 2012 00:04:14 -0700 Subject: [PATCH 52/84] add docs for new config param cache_jobs --- doc/ref/configuration/minion.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst index cfb79de84758..8fd86a1160ca 100644 --- a/doc/ref/configuration/minion.rst +++ b/doc/ref/configuration/minion.rst @@ -99,8 +99,27 @@ The location for minion cache data. cachedir: /var/cache/salt +.. conf_minion:: cache_jobs + +``cache_jobs`` +-------------- + +Default: ``False`` + +The minion can locally cache the return data from jobs sent to it, this +can be a good way to keep track minion side of the jobs the minion has +executed. By default this feature is disabled, to enable set cache_jobs +to True + +.. code-block:: yaml + + cache_jobs: False + .. conf_minion:: acceptance_wait_time +``acceptance_wait_time`` +------------------------ + Default: ``10`` The number of seconds to wait until attempting to re-authenticate with the From 8e5a3a2ae6fa5be9536948ee1fbc07c6409d6b6f Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Wed, 18 Jan 2012 00:12:28 -0700 Subject: [PATCH 53/84] make the minions return to the master in addition to returning to returners --- salt/minion.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index 08cb0754116e..c28e5dd40760 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -226,6 +226,7 @@ def _thread_return(self, data): ret['jid'] = data['jid'] ret['fun'] = data['fun'] + self._return_pub(ret) if data['ret']: ret['id'] = self.opts['id'] try: @@ -237,8 +238,6 @@ def _thread_return(self, data): exc ) ) - else: - self._return_pub(ret) def _thread_multi_return(self, data): ''' @@ -271,6 +270,7 @@ def _thread_multi_return(self, data): ) ret['return'][data['fun'][ind]] = trb ret['jid'] = data['jid'] + self._return_pub(ret) if data['ret']: ret['id'] = self.opts['id'] try: @@ -279,8 +279,6 @@ def _thread_multi_return(self, data): log.error('The return failed for job {0} {1}'.format( data['jid'], exc )) - else: - self._return_pub(ret) def _return_pub(self, ret, ret_cmd='_return'): ''' From 7269f98881d953cc5537144e702b6fb37d4eae6f Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Wed, 18 Jan 2012 00:18:09 -0700 Subject: [PATCH 54/84] Add capability to designate multiple returns --- salt/minion.py | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/salt/minion.py b/salt/minion.py index c28e5dd40760..dfe45193214f 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -228,16 +228,17 @@ def _thread_return(self, data): ret['fun'] = data['fun'] self._return_pub(ret) if data['ret']: - ret['id'] = self.opts['id'] - try: - self.returners[data['ret']](ret) - except Exception as exc: - log.error( - 'The return failed for job {0} {1}'.format( - data['jid'], - exc + for returner in set(data['ret'].split(',')): + ret['id'] = self.opts['id'] + try: + self.returners[returner](ret) + except Exception as exc: + log.error( + 'The return failed for job {0} {1}'.format( + data['jid'], + exc + ) ) - ) def _thread_multi_return(self, data): ''' @@ -272,13 +273,17 @@ def _thread_multi_return(self, data): ret['jid'] = data['jid'] self._return_pub(ret) if data['ret']: - ret['id'] = self.opts['id'] - try: - self.returners[data['ret']](ret) - except Exception as exc: - log.error('The return failed for job {0} {1}'.format( - data['jid'], exc - )) + for returner in set(data['ret'].split(',')): + ret['id'] = self.opts['id'] + try: + self.returners[returner](ret) + except Exception as exc: + log.error( + 'The return failed for job {0} {1}'.format( + data['jid'], + exc + ) + ) def _return_pub(self, ret, ret_cmd='_return'): ''' From 172b3037d4b93238063188fc32dd06d2f2355968 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Wed, 18 Jan 2012 00:28:10 -0700 Subject: [PATCH 55/84] only run the apache module if apachectl is installed --- salt/modules/apache.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/salt/modules/apache.py b/salt/modules/apache.py index a952e90d725c..84464bf303b3 100755 --- a/salt/modules/apache.py +++ b/salt/modules/apache.py @@ -3,12 +3,23 @@ ''' import re +import salt.utils __outputter__ = { 'signal': 'txt', } +def __virtual__(): + ''' + Only load the module if apache is installed + ''' + cmd = __detect_os() + if salt.utils.which(cmd): + return 'apache' + return False + + def __detect_os(): ''' Apache commands and paths differ depending on packaging From 21f20b12589695c7186f364fe881e14febe0c39f Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Wed, 18 Jan 2012 00:38:53 -0700 Subject: [PATCH 56/84] only load solr module if solr is installed --- salt/modules/solr.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/salt/modules/solr.py b/salt/modules/solr.py index 7d9af8ba28b1..4eff2e24a731 100644 --- a/salt/modules/solr.py +++ b/salt/modules/solr.py @@ -59,11 +59,15 @@ Get verbose output ''' +# Import Python Libs import urllib2 import json import socket import os +# Import Salt libs +import salt.utils + #sane defaults __opts__ = {'solr.cores': [], 'solr.host': 'localhost', @@ -86,16 +90,11 @@ def __virtual__(): Solr needs to be installed to use this. Return: str/bool:: - - TODO:// currently __salt__ is not available to call in this method because - all the salt modules have not been loaded yet. Use a grains module? ''' - return 'solr' - names = ['solr', 'apache-solr'] - for name in names: - if __salt__['pkg.version'](name): - return 'solr' - + if salt.utils.which('solr'): + return 'solr' + if salt.utils.which('apache-solr'): + return 'solr' return False def _get_none_or_value(value): From 46c7798003ce2eef60440860cc305372bd73a57d Mon Sep 17 00:00:00 2001 From: Byron Clark Date: Wed, 18 Jan 2012 09:22:18 -0700 Subject: [PATCH 57/84] Debug statement used the wrong variable. --- salt/returners/cassandra_return.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/returners/cassandra_return.py b/salt/returners/cassandra_return.py index 588f3e6e303b..971640fe40c6 100644 --- a/salt/returners/cassandra_return.py +++ b/salt/returners/cassandra_return.py @@ -43,5 +43,5 @@ def returner(ret): else: columns['return'] = str(ret['return']) - log.debug(back) + log.debug(columns) cf.insert(ret['jid'], columns) From afc975f7abfaf4e584dcce3903bedbeb62b0c2c2 Mon Sep 17 00:00:00 2001 From: Frank Klaassen Date: Wed, 18 Jan 2012 19:09:20 +0100 Subject: [PATCH 58/84] Only load nginx on machines that have nginx installed --- salt/modules/nginx.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/salt/modules/nginx.py b/salt/modules/nginx.py index 0769332e7d01..8177377eb8f4 100755 --- a/salt/modules/nginx.py +++ b/salt/modules/nginx.py @@ -2,10 +2,24 @@ Support for nginx ''' +import salt.utils + __outputter__ = { 'signal': 'txt', } +def __virtual__(): + ''' + Only load the module if nginx is installed + ''' + cmd = __detect_os() + if salt.utils.which(cmd): + return 'nginx' + return False + +def __detect_os(): + return 'nginx' + def version(): ''' Return server version from nginx -v From a2ff2e9cf73f399db1b6c0dc83839d32a8dd6fef Mon Sep 17 00:00:00 2001 From: Frank Klaassen Date: Wed, 18 Jan 2012 19:10:24 +0100 Subject: [PATCH 59/84] Make it more like the apache module --- salt/modules/nginx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/nginx.py b/salt/modules/nginx.py index 8177377eb8f4..fd78ab74c662 100755 --- a/salt/modules/nginx.py +++ b/salt/modules/nginx.py @@ -28,7 +28,7 @@ def version(): salt '*' nginx.version ''' - cmd = 'nginx -v' + cmd = __detect_os() + ' -v' out = __salt__['cmd.run'](cmd).split('\n') ret = out[0].split(': ') return ret[2] @@ -51,7 +51,7 @@ def signal(signal=None): arguments = ' -s {0}'.format(signal) else: arguments = ' {0}'.format(signal) - cmd = 'nginx' + arguments + cmd = __detect_os() + arguments out = __salt__['cmd.run_all'](cmd) # A non-zero return code means fail From fdd44146037b9cd3d58acf74bfa62c58e5ec487b Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Wed, 18 Jan 2012 10:14:47 -0800 Subject: [PATCH 60/84] Fixed copyright file --- debian/copyright | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/copyright b/debian/copyright index 9fc9484c3134..b548adad1636 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,10 +1,10 @@ Format: http://dep.debian.net/deps/dep5 Upstream-Name: salt -Upstream-Contact: Aaron Toponce -Source: http://github.com/thatch45/salt/ +Upstream-Contact: salt-users@googlegroups.com +Source: https://github.com/downloads/saltstack/salt/salt-0.9.5.tar.gz Files: * -Copyright: 2011 Thomas S Hatch +Copyright: 2012 Thomas S Hatch License: Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From f81e8810ae0b0e96bbf734b909cd690154798ad1 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Wed, 18 Jan 2012 10:42:07 -0800 Subject: [PATCH 61/84] Fixed lintian --- debian/source/lintian-overrides | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 debian/source/lintian-overrides diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides new file mode 100644 index 000000000000..caf9e9d79504 --- /dev/null +++ b/debian/source/lintian-overrides @@ -0,0 +1,3 @@ +salt-common: manpage-has-errors-from-man usr/share/man/man7/salt.7.gz +# The man page renders correctly, no need for lintian to get upset about +# it. From 61271bf53bf086526848c3a73910f0e289de34c9 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Wed, 18 Jan 2012 11:54:33 -0800 Subject: [PATCH 62/84] Fixed overrides --- debian/{source => }/lintian-overrides | 0 debian/salt-common.install | 1 + 2 files changed, 1 insertion(+) rename debian/{source => }/lintian-overrides (100%) diff --git a/debian/source/lintian-overrides b/debian/lintian-overrides similarity index 100% rename from debian/source/lintian-overrides rename to debian/lintian-overrides diff --git a/debian/salt-common.install b/debian/salt-common.install index 06237cb262af..3b0e763edc6e 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -22,3 +22,4 @@ salt/cli /usr/share/salt/ salt/states /usr/share/salt/ salt/utils /usr/share/salt/ usr/lib/python2*/dist-packages/salt/msgpack +debian/lintian-overrides /usr/share/lintian/overrides/salt-common From dfd82ad0bd33d892e0025d76a70997e2f1ebb1f2 Mon Sep 17 00:00:00 2001 From: Corey Quinn Date: Mon, 16 Jan 2012 15:36:59 -0800 Subject: [PATCH 63/84] Debian/Ubuntu package for upstream acceptance Applying latest changes for packaging Fixed typos in man pages Latest round of changes More packaging fixups Fixed salt-common typo Fixed wildcarding in install files Removed extra man pages Removed trailing slash Fixed links Moved binaries to proper packages Fixed man pages Pathing Perms tweak Missing files Fixed spacing Fixed another lintian error build the msgpack stuff Updating rules and install files Fixed shebang Control updates Fixed copyright file Fixed lintian Fixed overrides cmd.retcode no longer uses subprocess.call since it is broken fix issue with source_hash and trailing whitespace Bye-bye pickle, hello msgpack Add docs for new source powers Add support for source_hash to be a source hash string add pure python template type add return clarifying that no states were found if no states are found change some strings to use format add code to cache jobs on the minion if option is set serialize cache data was caching the wrong line data Add cache_jobs to the minion config template add docs for new config param cache_jobs make the minions return to the master in addition to returning to returners Add capability to designate multiple returns only run the apache module if apachectl is installed only load solr module if solr is installed Debug statement used the wrong variable. Only load nginx on machines that have nginx installed Make it more like the apache module --- conf/minion.template | 10 ++- debian/changelog | 2 +- debian/control | 50 +++++++------ debian/copyright | 6 +- debian/lintian-overrides | 3 + debian/rules | 5 +- debian/salt-common.install | 34 ++++++--- debian/salt-common.manpages | 1 + debian/salt-master.install | 7 +- debian/{links => salt-master.links} | 3 - debian/salt-master.manpages | 5 +- debian/salt-minion.install | 8 +-- debian/salt-minion.links | 2 + debian/salt-syndic.install | 1 + debian/salt-syndic.links | 1 + debian/salt.manpages | 9 --- doc/man/salt-cp.1 | 6 +- doc/man/salt.7 | 13 ++-- doc/ref/cli/salt-cp.rst | 6 +- doc/ref/configuration/minion.rst | 19 +++++ doc/topics/index.rst | 3 +- salt/__init__.py | 0 salt/config.py | 1 + salt/log.py | 0 salt/minion.py | 63 ++++++++++++----- salt/modules/apache.py | 11 +++ salt/modules/cmd.py | 2 +- salt/modules/mysql.py | 0 salt/modules/nginx.py | 18 ++++- salt/modules/solr.py | 17 +++-- salt/returners/cassandra_return.py | 2 +- salt/state.py | 8 +++ salt/states/file.py | 106 ++++++++++++++++++++++------ salt/states/mysql_database.py | 0 salt/states/mysql_user.py | 0 salt/utils/find.py | 0 scripts/salt | 2 +- scripts/salt-call | 2 +- scripts/salt-cp | 2 +- scripts/salt-key | 2 +- scripts/salt-master | 2 +- scripts/salt-minion | 2 +- scripts/salt-run | 2 +- scripts/salt-syndic | 2 +- 44 files changed, 305 insertions(+), 133 deletions(-) create mode 100644 debian/lintian-overrides create mode 100644 debian/salt-common.manpages rename debian/{links => salt-master.links} (59%) create mode 100644 debian/salt-minion.links create mode 100644 debian/salt-syndic.links delete mode 100644 debian/salt.manpages mode change 100755 => 100644 salt/__init__.py mode change 100755 => 100644 salt/log.py mode change 100755 => 100644 salt/modules/apache.py mode change 100755 => 100644 salt/modules/mysql.py mode change 100755 => 100644 salt/modules/nginx.py mode change 100755 => 100644 salt/states/mysql_database.py mode change 100755 => 100644 salt/states/mysql_user.py mode change 100755 => 100644 salt/utils/find.py diff --git a/conf/minion.template b/conf/minion.template index 669ff76f6c12..3d739a4998e0 100644 --- a/conf/minion.template +++ b/conf/minion.template @@ -29,10 +29,16 @@ # Where cache data goes #cachedir: /var/cache/salt +# The minion can locally cache the return data from jobs sent to it, this +# can be a good way to keep track minion side of the jobs the minion has +# executed. By default this feature is disabled, to enable set cache_jobs +# to True +#cache_jobs: False + # When waiting for a master to accept the minion's public key, salt will -# contiuously attempt to reconnect until successful. This is the time, in +# continuously attempt to reconnect until successful. This is the time, in # seconds, between those reconnection attempts. -# acceptance_wait_time = 10 +#acceptance_wait_time = 10 diff --git a/debian/changelog b/debian/changelog index 52368b3f1704..719d4de5c145 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -salt (0.9.5+git20111227.g8182e48-1) unstable; urgency=low +salt (0.9.5-1) unstable; urgency=low * First package release. (Closes: #643789) diff --git a/debian/control b/debian/control index b353685884b8..6ba30ed2e248 100644 --- a/debian/control +++ b/debian/control @@ -7,14 +7,11 @@ Build-Depends: debhelper (>= 7.0.50~), cython, python-yaml, python-setuptools, - python-yaml, python-crypto, python-m2crypto, python-zmq (>= 2.1.9), - libzmq1 (>= 2.1.9), libzmq-dev (>= 2.1.9), - python (>= 2.6), - python-dev (>= 2.6), + python-all-dev, python-jinja2 Standards-Version: 3.9.2 Homepage: http://saltstack.org @@ -24,8 +21,20 @@ Homepage: http://saltstack.org Package: salt-common Architecture: any -Depends: ${python:Depends}, - ${misc:Depends} +Depends: ${python:Depends}, + ${misc:Depends}, + ${shlibs:Depends}, + python-support, + cython, + python-setuptools, + python-yaml, + python-crypto, + python-m2crypto, + python-zmq (>= 2.1.9), + libzmq-dev (>= 2.1.9), + python, + python-dev, + python-jinja2 Description: Shared libraries that salt requires for all packages This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -41,15 +50,14 @@ Description: Shared libraries that salt requires for all packages Between the remote execution system, and state management Salt addresses the backbone of cloud and data center management. . - This particular package provides shared libraries that salt-master, salt-minion, - and salt-syndic require to function. - + This particular package provides shared libraries that salt-master, + salt-minion, and salt-syndic require to function. Package: salt-master Architecture: all -Depends: ${python:Depends}, - ${misc:Depends}, - salt-common +Depends: ${misc:Depends}, + python, + salt-common (>= ${source:Version}) Description: This package provides a remote manager to administer servers via salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -70,9 +78,9 @@ Description: This package provides a remote manager to administer servers via sa Package: salt-minion Architecture: all -Depends: ${python:Depends}, - ${misc:Depends}, - salt-common +Depends: ${misc:Depends}, + python, + salt-common (>= ${source:Version}) Description: This package represents the client package for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. @@ -93,10 +101,10 @@ Description: This package represents the client package for salt Package: salt-syndic Architecture: all -Depends: ${python:Depends}, - ${misc:Depends}, - salt-master -Description: salt-syndic represents the master-of-masters for salt +Depends: ${misc:Depends}, + python, + salt-master (>= ${source:Version}) +Description: This package represents the master-of-masters for salt This package is a powerful remote execution manager that can be used to administer servers in a fast and efficient way. . @@ -111,5 +119,5 @@ Description: salt-syndic represents the master-of-masters for salt Between the remote execution system, and state management Salt addresses the backbone of cloud and data center management. . - This particular package provides the master of masters for salt-- it enables the management - of multiple masters at a time. + This particular package provides the master of masters for salt-- it enables + the management of multiple masters at a time. diff --git a/debian/copyright b/debian/copyright index 9fc9484c3134..b548adad1636 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,10 +1,10 @@ Format: http://dep.debian.net/deps/dep5 Upstream-Name: salt -Upstream-Contact: Aaron Toponce -Source: http://github.com/thatch45/salt/ +Upstream-Contact: salt-users@googlegroups.com +Source: https://github.com/downloads/saltstack/salt/salt-0.9.5.tar.gz Files: * -Copyright: 2011 Thomas S Hatch +Copyright: 2012 Thomas S Hatch License: Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/debian/lintian-overrides b/debian/lintian-overrides new file mode 100644 index 000000000000..caf9e9d79504 --- /dev/null +++ b/debian/lintian-overrides @@ -0,0 +1,3 @@ +salt-common: manpage-has-errors-from-man usr/share/man/man7/salt.7.gz +# The man page renders correctly, no need for lintian to get upset about +# it. diff --git a/debian/rules b/debian/rules index a140040585e6..04dfdf8f2887 100755 --- a/debian/rules +++ b/debian/rules @@ -1,8 +1,7 @@ #!/usr/bin/make -f - +#export DH_VERBOSE=1 %: - dh $@ - + dh $@ --buildsystem=python_distutils #override_dh_installinit: # dh_installinit --no-start --name="salt-master" # dh_installinit --no-start --name="salt-minion" diff --git a/debian/salt-common.install b/debian/salt-common.install index 8ef4a2454ea8..3b0e763edc6e 100644 --- a/debian/salt-common.install +++ b/debian/salt-common.install @@ -1,9 +1,25 @@ -usr/share/man/man1/salt-minion.1 -usr/share/man/man1/salt-call.1 -usr/share/man/man1/salt-key.1 -usr/share/man/man1/salt-master.1 -usr/share/man/man1/salt-syndic.1 -usr/share/man/man1/salt-cp.1 -usr/share/man/man1/salt.1 -conf/minion /etc/salt/minion -salt/* /usr/share/salt/ +salt/exceptions.py /usr/share/salt +salt/loader.py /usr/share/salt +salt/master.py /usr/share/salt +salt/client.py /usr/share/salt +salt/runner.py /usr/share/salt +salt/output.py /usr/share/salt +salt/minion.py /usr/share/salt +salt/version.py /usr/share/salt +salt/config.py /usr/share/salt +salt/state.py /usr/share/salt +salt/log.py /usr/share/salt +salt/__init__.py /usr/share/salt +salt/payload.py /usr/share/salt +salt/crypt.py /usr/share/salt +salt/runners /usr/share/salt/ +salt/renderers /usr/share/salt/ +salt/returners /usr/share/salt/ +salt/ext /usr/share/salt/ +salt/msgpack /usr/share/salt/ +salt/grains /usr/share/salt/ +salt/cli /usr/share/salt/ +salt/states /usr/share/salt/ +salt/utils /usr/share/salt/ +usr/lib/python2*/dist-packages/salt/msgpack +debian/lintian-overrides /usr/share/lintian/overrides/salt-common diff --git a/debian/salt-common.manpages b/debian/salt-common.manpages new file mode 100644 index 000000000000..ce2ea1742d68 --- /dev/null +++ b/debian/salt-common.manpages @@ -0,0 +1 @@ +doc/man/salt.7 diff --git a/debian/salt-master.install b/debian/salt-master.install index 53d4c1340db6..80e93e1cacb6 100644 --- a/debian/salt-master.install +++ b/debian/salt-master.install @@ -1 +1,6 @@ -conf/master /etc/salt/master +conf/master.template /etc/salt/master +scripts/salt-key /usr/share/salt +scripts/salt /usr/share/salt +scripts/salt-run /usr/share/salt +scripts/salt-cp /usr/share/salt +scripts/salt-master /usr/share/salt diff --git a/debian/links b/debian/salt-master.links similarity index 59% rename from debian/links rename to debian/salt-master.links index e325b02fa1d7..0b3afffea41c 100644 --- a/debian/links +++ b/debian/salt-master.links @@ -1,8 +1,5 @@ usr/share/salt/salt /usr/bin/salt usr/share/salt/salt-master /usr/bin/salt-master -usr/share/salt/salt-syndic /usr/bin/salt-syndic usr/share/salt/salt-cp /usr/bin/salt-cp usr/share/salt/salt-key /usr/bin/salt-key usr/share/salt/salt-run /usr/bin/salt-run -usr/share/salt/salt-minion /usr/bin/salt-minion -usr/share/salt/salt-call /usr/bin/salt-call diff --git a/debian/salt-master.manpages b/debian/salt-master.manpages index 074f304fb2c4..52beb2836be5 100644 --- a/debian/salt-master.manpages +++ b/debian/salt-master.manpages @@ -1,6 +1,5 @@ -doc/man/salt.7 doc/man/salt.1 -doc/man/salt-master.1 -doc/man/salt-key.1 doc/man/salt-cp.1 +doc/man/salt-key.1 +doc/man/salt-master.1 doc/man/salt-run.1 diff --git a/debian/salt-minion.install b/debian/salt-minion.install index 7ed61cee7ef1..03f11693026b 100644 --- a/debian/salt-minion.install +++ b/debian/salt-minion.install @@ -1,4 +1,4 @@ -scripts/salt-minion /usr/share/salt/salt-minion -scripts/salt-call /usr/share/salt/salt-call -modules/* /usr/share/salt/modules/ -conf/minion /etc/salt/minion +scripts/salt-minion /usr/share/salt +scripts/salt-call /usr/share/salt +salt/modules /usr/share/salt/modules +conf/minion.template /etc/salt/minion diff --git a/debian/salt-minion.links b/debian/salt-minion.links new file mode 100644 index 000000000000..599cef31fd49 --- /dev/null +++ b/debian/salt-minion.links @@ -0,0 +1,2 @@ +usr/share/salt/salt-minion /usr/bin/salt-minion +usr/share/salt/salt-call /usr/bin/salt-call diff --git a/debian/salt-syndic.install b/debian/salt-syndic.install index e69de29bb2d1..e4bc32428113 100644 --- a/debian/salt-syndic.install +++ b/debian/salt-syndic.install @@ -0,0 +1 @@ +scripts/salt-syndic /usr/share/salt diff --git a/debian/salt-syndic.links b/debian/salt-syndic.links new file mode 100644 index 000000000000..3edb1ec97d7d --- /dev/null +++ b/debian/salt-syndic.links @@ -0,0 +1 @@ +usr/share/salt/salt-syndic /usr/bin/salt-syndic diff --git a/debian/salt.manpages b/debian/salt.manpages deleted file mode 100644 index 43d8412c8da2..000000000000 --- a/debian/salt.manpages +++ /dev/null @@ -1,9 +0,0 @@ -doc/man/salt.1 -doc/man/salt.7 -doc/man/salt-call.1 -doc/man/salt-cp.1 -doc/man/salt-key.1 -doc/man/salt-master.1 -doc/man/salt-minion.1 -doc/man/salt-run.1 -doc/man/salt-syndic.1 diff --git a/doc/man/salt-cp.1 b/doc/man/salt-cp.1 index e0196f6f49d8..71d01834d2cd 100644 --- a/doc/man/salt-cp.1 +++ b/doc/man/salt-cp.1 @@ -61,7 +61,7 @@ The timeout in seconds to wait for replies from the salt minions. .INDENT 0.0 .TP .B \-E, \-\-pcre -The target expresion will be interpereted as a pcre regular expression +The target expression will be interpereted as a pcre regular expression rather than a shell glob. .UNINDENT .INDENT 0.0 @@ -74,8 +74,8 @@ example: server1.foo.bar,server2.foo.bar,example7.quo.qux .TP .B \-G, \-\-grain The target expression matches values returned by the salt grains system on -the minions. The target expresion is in the format of \(aq:\(aq; example: \(aqos:Arch.*\(aq +the minions. The target expression is in the format of \(aq:\(aq; example: \(aqos:Arch.*\(aq .UNINDENT .INDENT 0.0 .TP diff --git a/doc/man/salt.7 b/doc/man/salt.7 index 7545aabab458..0f9d1c7253e4 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -7827,7 +7827,7 @@ extra information needs to be sent with the publications, the order_masters option makes sure that the extra data is sent out. .SS Running the Syndic .sp -The Syndic is a seperate daemon that needs to be started on the master that is +The Syndic is a separate daemon that needs to be started on the master that is controlled by a higher master. Starting the Syndic daemon is the same as starting the other Salt daemons. .sp @@ -8149,7 +8149,7 @@ def get_file(path, dest, env=\(aqbase\(aq): # syndic servers(s) below it set the "order_masters" setting to True, if this # is a master that will be running a syndic daemon for passthrough the # "syndic_master" setting needs to be set to the location of the master server -# to recieve commands from +# to receive commands from # # Set the order_masters setting to True if this master will command lower # masters\(aq syndic interfaces @@ -8608,7 +8608,7 @@ master. Using the syndic is simple, if this is a master that will have syndic servers(s) below it set the "order_masters" setting to True, if this is a master that will be running a syndic daemon for passthrough the "syndic_master" setting needs to be set to the location of the master server -to recieve commands from +to receive commands from .SS \fBorder_masters\fP .sp Default: \fBFalse\fP @@ -9443,7 +9443,7 @@ The timeout in seconds to wait for replies from the salt minions. .INDENT 0.0 .TP .B \-E, \-\-pcre -The target expresion will be interpereted as a pcre regular expression +The target expression will be interpereted as a pcre regular expression rather than a shell glob. .UNINDENT .INDENT 0.0 @@ -9456,8 +9456,8 @@ example: server1.foo.bar,server2.foo.bar,example7.quo.qux .TP .B \-G, \-\-grain The target expression matches values returned by the salt grains system on -the minions. The target expresion is in the format of \(aq:\(aq; example: \(aqos:Arch.*\(aq +the minions. The target expression is in the format of \(aq:\(aq; example: \(aqos:Arch.*\(aq .UNINDENT .INDENT 0.0 .TP @@ -11192,5 +11192,4 @@ Thomas S. Hatch and many others, please see the Authors file .SH COPYRIGHT 2011, Thomas S. Hatch .\" Generated by docutils manpage writer. -.\" . diff --git a/doc/ref/cli/salt-cp.rst b/doc/ref/cli/salt-cp.rst index 977aec2dd48d..de338d9a35ef 100644 --- a/doc/ref/cli/salt-cp.rst +++ b/doc/ref/cli/salt-cp.rst @@ -36,7 +36,7 @@ Options .. option:: -E, --pcre - The target expresion will be interpereted as a pcre regular expression + The target expression will be interpereted as a pcre regular expression rather than a shell glob. .. option:: -L, --list @@ -47,8 +47,8 @@ Options .. option:: -G, --grain The target expression matches values returned by the salt grains system on - the minions. The target expresion is in the format of ':'; example: 'os:Arch.*' + the minions. The target expression is in the format of ':'; example: 'os:Arch.*' .. option:: -Q, --query diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst index cfb79de84758..8fd86a1160ca 100644 --- a/doc/ref/configuration/minion.rst +++ b/doc/ref/configuration/minion.rst @@ -99,8 +99,27 @@ The location for minion cache data. cachedir: /var/cache/salt +.. conf_minion:: cache_jobs + +``cache_jobs`` +-------------- + +Default: ``False`` + +The minion can locally cache the return data from jobs sent to it, this +can be a good way to keep track minion side of the jobs the minion has +executed. By default this feature is disabled, to enable set cache_jobs +to True + +.. code-block:: yaml + + cache_jobs: False + .. conf_minion:: acceptance_wait_time +``acceptance_wait_time`` +------------------------ + Default: ``10`` The number of seconds to wait until attempting to re-authenticate with the diff --git a/doc/topics/index.rst b/doc/topics/index.rst index 756b16c7ceac..7340c3fb8904 100644 --- a/doc/topics/index.rst +++ b/doc/topics/index.rst @@ -45,9 +45,10 @@ contains a viable, and transparent, AMQ broker inside the daemon. Salt uses public keys for authentication with the master daemon, then uses faster AES encryption for payload communication, this means that authentication and encryption are also built into Salt. Salt takes advantage of communication via -Python pickles, enabling fast and light network traffic. +`msgpack`_, enabling fast and light network traffic. .. _`ZeroMQ`: http://www.zeromq.org/ +.. _`msgpack`: http://msgpack.org/ Python client interface ======================= diff --git a/salt/__init__.py b/salt/__init__.py old mode 100755 new mode 100644 diff --git a/salt/config.py b/salt/config.py index 5863c444ca9a..641605980faa 100644 --- a/salt/config.py +++ b/salt/config.py @@ -80,6 +80,7 @@ def minion_config(path): 'pki_dir': '/etc/salt/pki', 'id': socket.getfqdn(), 'cachedir': '/var/cache/salt', + 'cache_jobs': False, 'conf_file': path, 'renderer': 'yaml_jinja', 'failhard': False, diff --git a/salt/log.py b/salt/log.py old mode 100755 new mode 100644 diff --git a/salt/minion.py b/salt/minion.py index 8f6d3583b269..dfe45193214f 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -226,14 +226,19 @@ def _thread_return(self, data): ret['jid'] = data['jid'] ret['fun'] = data['fun'] + self._return_pub(ret) if data['ret']: - ret['id'] = self.opts['id'] - try: - self.returners[data['ret']](ret) - except Exception as exc: - log.error('The return failed for job %s %s', data['jid'], exc) - else: - self._return_pub(ret) + for returner in set(data['ret'].split(',')): + ret['id'] = self.opts['id'] + try: + self.returners[returner](ret) + except Exception as exc: + log.error( + 'The return failed for job {0} {1}'.format( + data['jid'], + exc + ) + ) def _thread_multi_return(self, data): ''' @@ -259,23 +264,32 @@ def _thread_multi_return(self, data): = self.functions[data['fun'][ind]](*data['arg'][ind]) except Exception as exc: trb = traceback.format_exc() - log.warning('The minion function caused an exception: %s', exc) + log.warning( + 'The minion function caused an exception: {0}'.format( + exc + ) + ) ret['return'][data['fun'][ind]] = trb ret['jid'] = data['jid'] + self._return_pub(ret) if data['ret']: - ret['id'] = self.opts['id'] - try: - self.returners[data['ret']](ret) - except Exception as exc: - log.error('The return failed for job %s %s', data['jid'], exc) - else: - self._return_pub(ret) + for returner in set(data['ret'].split(',')): + ret['id'] = self.opts['id'] + try: + self.returners[returner](ret) + except Exception as exc: + log.error( + 'The return failed for job {0} {1}'.format( + data['jid'], + exc + ) + ) def _return_pub(self, ret, ret_cmd='_return'): ''' Return the data from the executed command to the master server ''' - log.info('Returning information for job: %(jid)s', ret) + log.info('Returning information for job: {0}'.format(ret['jid'])) context = zmq.Context() socket = context.socket(zmq.REQ) socket.connect(self.opts['master_uri']) @@ -301,8 +315,21 @@ def _return_pub(self, ret, ret_cmd='_return'): except KeyError: pass payload['load'] = self.crypticle.dumps(load) - socket.send(self.serial.dumps(payload)) - return socket.recv() + data = self.serial.dumps(payload) + socket.send(data) + ret_val = socket.recv() + if self.opts['cache_jobs']: + # Local job cache has been enabled + fn_ = os.path.join( + self.opts['cachedir'], + 'minion_jobs', + load['jid'], + 'return.p') + jdir = os.path.dirname(fn_) + if not os.path.isdir(jdir): + os.makedirs(jdir) + open(fn_, 'w+').write(self.serial.dumps(ret)) + return ret_val def authenticate(self): ''' diff --git a/salt/modules/apache.py b/salt/modules/apache.py old mode 100755 new mode 100644 index a952e90d725c..84464bf303b3 --- a/salt/modules/apache.py +++ b/salt/modules/apache.py @@ -3,12 +3,23 @@ ''' import re +import salt.utils __outputter__ = { 'signal': 'txt', } +def __virtual__(): + ''' + Only load the module if apache is installed + ''' + cmd = __detect_os() + if salt.utils.which(cmd): + return 'apache' + return False + + def __detect_os(): ''' Apache commands and paths differ depending on packaging diff --git a/salt/modules/cmd.py b/salt/modules/cmd.py index 4586386d50f0..c49cea564680 100644 --- a/salt/modules/cmd.py +++ b/salt/modules/cmd.py @@ -123,7 +123,7 @@ def retcode(cmd, cwd=DEFAULT_CWD): salt '*' cmd.retcode "file /bin/bash" ''' log.info('Executing command {0} in directory {1}'.format(cmd, cwd)) - return subprocess.call(cmd, shell=True, cwd=cwd) + return _run(cmd, cwd=cwd)['retcode'] def has_exec(cmd): diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py old mode 100755 new mode 100644 diff --git a/salt/modules/nginx.py b/salt/modules/nginx.py old mode 100755 new mode 100644 index 0769332e7d01..fd78ab74c662 --- a/salt/modules/nginx.py +++ b/salt/modules/nginx.py @@ -2,10 +2,24 @@ Support for nginx ''' +import salt.utils + __outputter__ = { 'signal': 'txt', } +def __virtual__(): + ''' + Only load the module if nginx is installed + ''' + cmd = __detect_os() + if salt.utils.which(cmd): + return 'nginx' + return False + +def __detect_os(): + return 'nginx' + def version(): ''' Return server version from nginx -v @@ -14,7 +28,7 @@ def version(): salt '*' nginx.version ''' - cmd = 'nginx -v' + cmd = __detect_os() + ' -v' out = __salt__['cmd.run'](cmd).split('\n') ret = out[0].split(': ') return ret[2] @@ -37,7 +51,7 @@ def signal(signal=None): arguments = ' -s {0}'.format(signal) else: arguments = ' {0}'.format(signal) - cmd = 'nginx' + arguments + cmd = __detect_os() + arguments out = __salt__['cmd.run_all'](cmd) # A non-zero return code means fail diff --git a/salt/modules/solr.py b/salt/modules/solr.py index 7d9af8ba28b1..4eff2e24a731 100644 --- a/salt/modules/solr.py +++ b/salt/modules/solr.py @@ -59,11 +59,15 @@ Get verbose output ''' +# Import Python Libs import urllib2 import json import socket import os +# Import Salt libs +import salt.utils + #sane defaults __opts__ = {'solr.cores': [], 'solr.host': 'localhost', @@ -86,16 +90,11 @@ def __virtual__(): Solr needs to be installed to use this. Return: str/bool:: - - TODO:// currently __salt__ is not available to call in this method because - all the salt modules have not been loaded yet. Use a grains module? ''' - return 'solr' - names = ['solr', 'apache-solr'] - for name in names: - if __salt__['pkg.version'](name): - return 'solr' - + if salt.utils.which('solr'): + return 'solr' + if salt.utils.which('apache-solr'): + return 'solr' return False def _get_none_or_value(value): diff --git a/salt/returners/cassandra_return.py b/salt/returners/cassandra_return.py index 588f3e6e303b..971640fe40c6 100644 --- a/salt/returners/cassandra_return.py +++ b/salt/returners/cassandra_return.py @@ -43,5 +43,5 @@ def returner(ret): else: columns['return'] = str(ret['return']) - log.debug(back) + log.debug(columns) cf.insert(ret['jid'], columns) diff --git a/salt/state.py b/salt/state.py index c3a2f85e6f60..f588e96df5c7 100644 --- a/salt/state.py +++ b/salt/state.py @@ -989,6 +989,14 @@ def call_highstate(self): high, errors = self.render_highstate(matches) if errors: return errors + if not high: + return {'no.states': { + 'result': False, + 'comment': 'No states found for this minion', + 'name': 'No States', + 'changes': {} + } + } return self.state.call_high(high) def compile_highstate(self): diff --git a/salt/states/file.py b/salt/states/file.py index 73d2efb8e7dd..b7c92ef3636c 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -69,6 +69,7 @@ import shutil import difflib import hashlib +import imp import logging import tempfile import traceback @@ -223,6 +224,43 @@ def _jinja(sfn, name, source, user, group, mode, env, context=None): 'data': trb} +def _py(sfn, name, source, user, group, mode, env, context=None): + ''' + Render a template from a python source file + + Returns:: + + {'result': bool, + 'data': } + ''' + if not os.path.isfile(sfn): + return {} + + mod = imp.load_source( + os.path.basename(sfn).split('.')[0], + sfn + ) + mod.salt = __salt__ + mod.grains = __grains__ + mod.name = name + mod.source = source + mod.user = user + mod.group = group + mod.mode = mode + mod.env = env + mod.context = context + + try: + tgt = tempfile.mkstemp()[1] + open(tgt, 'w+').write(mod.run()) + return {'result': True, + 'data': tgt} + except: + trb = traceback.format_exc() + return {'result': False, + 'data': trb} + + def symlink(name, target, force=False, makedirs=False): ''' Create a symlink @@ -345,11 +383,21 @@ def managed(name, The location of the file to manage source - The source file, this file is located on the salt master file server - and is specified with the salt:// protocol. If the file is located on + The source file to download to the minion, this source file can be + hosted on either the salt master server, or on an http or ftp server. + For files hosted on the salt file server, if the file is located on the master in the directory named spam, and is called eggs, the source string is salt://spam/eggs. If source is left blank or None, the file - will be created as an empty file and the content will not be managed + will be created as an empty file and the content will not be managed + + If the file is hosted on a http or ftp server then the source_hash + argument is also required + + source_hash: + This can be either a file which contains a source hash string for + the source, or a source hash string. The source hash string is the + hash algorithm followed by the hash of the file: + md5=e138491e9d5b97023cea823fe17bac22 user The user to own the file, this defaults to the user salt is running as @@ -432,24 +480,40 @@ def managed(name, ret['comment'] = 'Source file {0} not found'.format(source) return ret elif source_hash: - hash_fn = __salt__['cp.cache_file'](source_hash) - if not hash_fn: - ret['result'] = False - ret['comment'] = 'Source hash file {0} not found'.format( - source_hash - ) - return ret - comps = open(hash_fn, 'r').read().split('=') - if len(comps) < 2: - ret['result'] = False - ret['comment'] = ('Source hash file {0} contains an ' - ' invalid hash format, it must be in ' - ' the format =').format( - source_hash - ) - return ret - source_sum['hsum'] = comps[1] - source_sum['hash_type'] = comps[0] + protos = ['salt', 'http', 'ftp'] + if urlparse.urlparse(source_hash).scheme in protos: + # The sourc_hash is a file on a server + hash_fn = __salt__['cp.cache_file'](source_hash) + if not hash_fn: + ret['result'] = False + ret['comment'] = 'Source hash file {0} not found'.format( + source_hash + ) + return ret + comps = open(hash_fn, 'r').read().split('=') + if len(comps) < 2: + ret['result'] = False + ret['comment'] = ('Source hash file {0} contains an ' + ' invalid hash format, it must be in ' + ' the format =').format( + source_hash + ) + return ret + source_sum['hsum'] = comps[1].strip() + source_sum['hash_type'] = comps[0].strip() + else: + # The source_hash is a hash string + comps = source_hash.split('=') + if len(comps) < 2: + ret['result'] = False + ret['comment'] = ('Source hash file {0} contains an ' + ' invalid hash format, it must be in ' + ' the format =').format( + source_hash + ) + return ret + source_sum['hsum'] = comps[1].strip() + source_sum['hash_type'] = comps[0].strip() else: ret['result'] = False ret['comment'] = ('Unable to determine upstream hash of' diff --git a/salt/states/mysql_database.py b/salt/states/mysql_database.py old mode 100755 new mode 100644 diff --git a/salt/states/mysql_user.py b/salt/states/mysql_user.py old mode 100755 new mode 100644 diff --git a/salt/utils/find.py b/salt/utils/find.py old mode 100755 new mode 100644 diff --git a/scripts/salt b/scripts/salt index 2c245c83f4cd..d38782886494 100755 --- a/scripts/salt +++ b/scripts/salt @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Publish commands to the salt system from the command line on the master. ''' diff --git a/scripts/salt-call b/scripts/salt-call index b2f3585b5bd7..0cee11d2f682 100755 --- a/scripts/salt-call +++ b/scripts/salt-call @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Directly call a salt command in the modules, does not require a running salt minion to run. diff --git a/scripts/salt-cp b/scripts/salt-cp index b38151d953cf..e3a1fa426e70 100755 --- a/scripts/salt-cp +++ b/scripts/salt-cp @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Publish commands to the salt system from the command line on the master. ''' diff --git a/scripts/salt-key b/scripts/salt-key index 0a0fec5112dc..e8a91d571aee 100755 --- a/scripts/salt-key +++ b/scripts/salt-key @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Manage the authentication keys with salt-key ''' diff --git a/scripts/salt-master b/scripts/salt-master index e409281e5cef..96e586685f24 100755 --- a/scripts/salt-master +++ b/scripts/salt-master @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Start the salt-master ''' diff --git a/scripts/salt-minion b/scripts/salt-minion index f6745445582b..d9e0782559f0 100755 --- a/scripts/salt-minion +++ b/scripts/salt-minion @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python ''' This script is used to kick off a salt minion daemon ''' diff --git a/scripts/salt-run b/scripts/salt-run index e5e996c96f32..0c933690065f 100755 --- a/scripts/salt-run +++ b/scripts/salt-run @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python ''' Execute a salt convenience routine ''' diff --git a/scripts/salt-syndic b/scripts/salt-syndic index b122993bfac9..5a46a52c450e 100755 --- a/scripts/salt-syndic +++ b/scripts/salt-syndic @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python ''' This script is used to kick off a salt syndic daemon ''' From 30308b6a5b97af8121780b24c635dee663e1992a Mon Sep 17 00:00:00 2001 From: Jeff Bauer Date: Wed, 18 Jan 2012 14:29:38 -0600 Subject: [PATCH 64/84] run salt in user space --- conf/master.template | 3 ++ conf/minion.template | 3 ++ salt/__init__.py | 112 ++++++++++++++++++++++++++++++----------- salt/config.py | 1 + salt/utils/__init__.py | 2 +- salt/utils/verify.py | 18 +------ 6 files changed, 91 insertions(+), 48 deletions(-) diff --git a/conf/master.template b/conf/master.template index 2aaf88313160..285d046f7588 100644 --- a/conf/master.template +++ b/conf/master.template @@ -7,6 +7,9 @@ # The port used by the publisher #publish_port: 4505 +# The user to run salt +#user: root + # The number of worker threads to start, these threads are used to manage # return calls made from minions to the master, if the master seems to be # running slowly, increase the number of threads diff --git a/conf/minion.template b/conf/minion.template index 669ff76f6c12..0c75833e5d04 100644 --- a/conf/minion.template +++ b/conf/minion.template @@ -8,6 +8,9 @@ # Set the post used by the master reply and authentication server #master_port: 4506 +# The user to run salt +#user: root + # The root directory prepended to these options: pki_dir, cachedir, log_file. #root_dir: / diff --git a/salt/__init__.py b/salt/__init__.py index 4b8dcafcfee9..a73c8ee53f8f 100755 --- a/salt/__init__.py +++ b/salt/__init__.py @@ -8,6 +8,7 @@ import sys import stat import optparse +import getpass # Import salt libs, the try block bypasses an issue at build time so that c # modules don't cause the build to fail @@ -42,6 +43,34 @@ def verify_env(dirs): salt.utils.verify.run() +def check_user(user, log): + ''' + Check user and assign process uid/gid. + ''' + if 'os' in os.environ: + if os.environ['os'].startswith('Windows'): + return True + if user == getpass.getuser(): + return True + import pwd # after confirming not running Windows + try: + p = pwd.getpwnam(user) + try: + os.setgid(p.pw_gid) + os.setuid(p.pw_uid) + except OSError: + if user == 'root': + msg = 'Sorry, the salt must run as root. http://xkcd.com/838' + else: + msg = 'Salt must be run from root or user "{0}"'.format(user) + log.critical(msg) + return False + except KeyError: + msg = 'User not found: "{0}"'.format(user) + log.critical(msg) + return False + return True + class Master(object): ''' Creates a master server @@ -49,6 +78,9 @@ class Master(object): def __init__(self): self.cli = self.__parse_cli() self.opts = salt.config.master_config(self.cli['config']) + # command line overrides config + if self.cli['user']: + self.opts['user'] = self.cli['user'] def __parse_cli(self): ''' @@ -67,6 +99,10 @@ def __parse_cli(self): dest='config', default='/etc/salt/master', help='Pass in an alternative configuration file') + parser.add_option('-u', + '--user', + dest='user', + help='Specify user to run minion') parser.add_option('-l', '--log-level', dest='log_level', @@ -104,13 +140,14 @@ def start(self): import logging log = logging.getLogger(__name__) # Late import so logging works correctly - import salt.master - master = salt.master.Master(self.opts) - if self.cli['daemon']: - # Late import so logging works correctly - import salt.utils - salt.utils.daemonize() - master.start() + if check_user(self.opts['user'], log): + import salt.master + master = salt.master.Master(self.opts) + if self.cli['daemon']: + # Late import so logging works correctly + import salt.utils + salt.utils.daemonize() + master.start() class Minion(object): @@ -120,6 +157,9 @@ class Minion(object): def __init__(self): self.cli = self.__parse_cli() self.opts = salt.config.minion_config(self.cli['config']) + # command line overrides config + if self.cli['user']: + self.opts['user'] = self.cli['user'] def __parse_cli(self): ''' @@ -138,6 +178,10 @@ def __parse_cli(self): dest='config', default='/etc/salt/minion', help='Pass in an alternative configuration file') + parser.add_option('-u', + '--user', + dest='user', + help='Specify user to run minion') parser.add_option('-l', '--log-level', dest='log_level', @@ -151,7 +195,8 @@ def __parse_cli(self): log_format = '%(asctime)s,%(msecs)03.0f [%(name)-15s][%(levelname)-8s] %(message)s' salt.log.setup_console_logger(options.log_level, log_format=log_format) cli = {'daemon': options.daemon, - 'config': options.config} + 'config': options.config, + 'user': options.user} return cli @@ -170,22 +215,21 @@ def start(self): ) for name, level in self.opts['log_granular_levels'].iteritems(): salt.log.set_logger_level(name, level) - import logging - # Late import so logging works correctly import salt.minion log = logging.getLogger(__name__) - try: - if self.cli['daemon']: - # Late import so logging works correctly - import salt.utils - salt.utils.daemonize() - minion = salt.minion.Minion(self.opts) - minion.tune_in() - except KeyboardInterrupt: - log.warn('Stopping the Salt Minion') - raise SystemExit('\nExiting on Ctrl-c') + if check_user(self.opts['user'], log): + try: + if self.cli['daemon']: + # Late import so logging works correctly + import salt.utils + salt.utils.daemonize() + minion = salt.minion.Minion(self.opts) + minion.tune_in() + except KeyboardInterrupt: + log.warn('Stopping the Salt Minion') + raise SystemExit('\nExiting on Ctrl-c') class Syndic(object): @@ -195,6 +239,9 @@ class Syndic(object): def __init__(self): self.cli = self.__parse_cli() self.opts = self.__prep_opts() + # command line overrides config + if self.cli['user']: + self.opts['user'] = self.cli['user'] def __prep_opts(self): ''' @@ -239,6 +286,10 @@ def __parse_cli(self): dest='minion_config', default='/etc/salt/minion', help='Pass in an alternative minion configuration file') + parser.add_option('-u', + '--user', + dest='user', + help='Specify user to run minion') parser.add_option('-l', '--log-level', dest='log_level', @@ -278,13 +329,14 @@ def start(self): # Late import so logging works correctly import salt.minion log = logging.getLogger(__name__) - try: - syndic = salt.minion.Syndic(self.opts) - if self.cli['daemon']: - # Late import so logging works correctly - import salt.utils - salt.utils.daemonize() - syndic.tune_in() - except KeyboardInterrupt: - log.warn('Stopping the Salt Syndic Minion') - raise SystemExit('\nExiting on Ctrl-c') + if check_user(self.opts['user'], log): + try: + syndic = salt.minion.Syndic(self.opts) + if self.cli['daemon']: + # Late import so logging works correctly + import salt.utils + salt.utils.daemonize() + syndic.tune_in() + except KeyboardInterrupt: + log.warn('Stopping the Salt Syndic Minion') + raise SystemExit('\nExiting on Ctrl-c') diff --git a/salt/config.py b/salt/config.py index 5863c444ca9a..bf76d4261d69 100644 --- a/salt/config.py +++ b/salt/config.py @@ -76,6 +76,7 @@ def minion_config(path): ''' opts = {'master': 'salt', 'master_port': '4506', + 'user': 'root', 'root_dir': '/', 'pki_dir': '/etc/salt/pki', 'id': socket.getfqdn(), diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 132d4ee7c4f5..b2ecf4d7ecf5 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -79,7 +79,7 @@ def daemonize(): win32api.ShellExecute( 0, 'runas', - executablepath, + executablepath, os.path.join(pypath[0], os.sep, pypath[1], 'Lib\\site-packages\\salt\\utils\\saltminionservice.py'), os.path.join(pypath[0], os.sep, pypath[1]), 0 ) diff --git a/salt/utils/verify.py b/salt/utils/verify.py index d43ad39a41ab..c4083f88b43e 100644 --- a/salt/utils/verify.py +++ b/salt/utils/verify.py @@ -3,13 +3,11 @@ ''' # Original Author: Jeff Schroeder -import os import sys import logging -import salt.log log = logging.getLogger(__name__) -__all__ = ('zmq_version', 'check_root', 'run') +__all__ = ('zmq_version', 'run') def zmq_version(): '''ZeroMQ python bindings >= 2.1.9 are required''' @@ -21,20 +19,6 @@ def zmq_version(): return False return True -def check_root(): - ''' - Most of the salt scripts need to run as root, this function will simply - verify that root is the user before the application discovers it. - ''' - if 'os' in os.environ: - if os.environ['os'].startswith('Windows'): - return True - msg = 'Sorry, the salt must run as root. http://xkcd.com/838' - if os.getuid(): - log.critical(msg) - return False - return True - def run(): for func in __all__: if func == "run": continue From 8628876f806637d80f19cf88f7e664be000f3b44 Mon Sep 17 00:00:00 2001 From: Jeff Bauer Date: Wed, 18 Jan 2012 15:07:57 -0600 Subject: [PATCH 65/84] add user to master config --- salt/__init__.py | 5 +++-- salt/config.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/salt/__init__.py b/salt/__init__.py index a73c8ee53f8f..b30cfdbef795 100755 --- a/salt/__init__.py +++ b/salt/__init__.py @@ -117,7 +117,8 @@ def __parse_cli(self): salt.log.setup_console_logger(options.log_level, log_format=log_format) cli = {'daemon': options.daemon, - 'config': options.config} + 'config': options.config, + 'user': options.user} return cli @@ -306,7 +307,7 @@ def __parse_cli(self): cli = {'daemon': options.daemon, 'minion_config': options.minion_config, 'master_config': options.master_config, - } + 'user': options.user} return cli diff --git a/salt/config.py b/salt/config.py index bf76d4261d69..db70be168215 100644 --- a/salt/config.py +++ b/salt/config.py @@ -132,6 +132,7 @@ def master_config(path): ''' opts = {'interface': '0.0.0.0', 'publish_port': '4505', + 'user': 'root', 'worker_threads': 5, 'sock_dir': os.path.join(tempfile.gettempdir(), '.salt-unix'), 'ret_port': '4506', From 18569c45c6982a5c193c7a5cb29ea6f9f3eb5c25 Mon Sep 17 00:00:00 2001 From: Evan Borgstrom Date: Wed, 18 Jan 2012 17:34:53 -0500 Subject: [PATCH 66/84] Allow the mysql module to be configured by a default_file This allows MySQL to be configured via a default file instead of by specifying the parameters individually in the minion config. Debian creates a file name /etc/mysql/debian.cnf that contains credentials for a user equivilent to 'root' so this allows for very convenient configuration of a minion. --- salt/modules/mysql.py | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/salt/modules/mysql.py b/salt/modules/mysql.py index 73d9b58c8bee..703272a30f42 100644 --- a/salt/modules/mysql.py +++ b/salt/modules/mysql.py @@ -10,6 +10,10 @@ mysql.user: 'root' mysql.pass: '' mysql.db: 'mysql' + +You can also use a defaults file:: + + mysql.default_file: '/etc/mysql/debian.cnf' ''' import logging @@ -53,20 +57,27 @@ def connect(**kwargs): ''' wrap authentication credentials here ''' - hostname = kwargs.get('host', __opts__['mysql.host']) - username = kwargs.get('user', __opts__['mysql.user']) - password = kwargs.get('pass', __opts__['mysql.pass']) - dbport = kwargs.get('port', __opts__['mysql.port']) - dbname = kwargs.get('db', __opts__['mysql.db']) - - db = MySQLdb.connect( - hostname, - username, - password, - dbname, - dbport, - ) - + connargs = dict() + def _connarg(name, key=None): + ''' + Add key to connargs, only if name exists in our + kwargs or as mysql. in __opts__ + ''' + if key is None: + key = name + if name in kwargs: + connargs[key] = kwargs[name] + elif 'mysql.%s' % name in __opts__: + connargs[key] = __opts__['mysql.%s' % name] + + _connarg('host') + _connarg('user') + _connarg('pass', 'passwd') + _connarg('port') + _connarg('db') + _connarg('default_file', 'read_default_file') + + db = MySQLdb.connect(**connargs) db.autocommit(True) return db @@ -484,4 +495,4 @@ def db_optimize(name, else: log.info("Optimizing table '%s' in db '%s'..".format(name,table,)) ret = __optimize_table(name,table) - return ret \ No newline at end of file + return ret From 1cffa188e533f7a5902a1559d85f1d83731cfa40 Mon Sep 17 00:00:00 2001 From: Evan Borgstrom Date: Wed, 18 Jan 2012 18:38:29 -0500 Subject: [PATCH 67/84] Minor documentation correction on 'context' & 'defaults' To ensure the YAML structure correctly assigns 'context' & 'defaults' as dicts the elements under context & defaults need an extra set of indents. Example: - example: test: 1 Compiles to: [{'example': None, 'test': 1}] While: - example: test: 1 Correctly compiles to: [{'example': {'test': 1}}] --- doc/man/salt.7 | 6 +++--- salt/states/file.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/man/salt.7 b/doc/man/salt.7 index 0f9d1c7253e4..cfc3da627819 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -6800,10 +6800,10 @@ makes use of the jinja templating system would look like this: \- mode: 644 \- template: jinja \- context: - custom_var: "override" + custom_var: "override" \- defaults: - custom_var: "default value" - other_var: 123 + custom_var: "default value" + other_var: 123 .ft P .fi .sp diff --git a/salt/states/file.py b/salt/states/file.py index b7c92ef3636c..4e0c7e878de9 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -22,10 +22,10 @@ - mode: 644 - template: jinja - context: - custom_var: "override" + custom_var: "override" - defaults: - custom_var: "default value" - other_var: 123 + custom_var: "default value" + other_var: 123 Directories can be managed via the ``directory`` function. This function can create and enforce the permissions on a directory. A directory statement will From e640764e2173335fcf6970b3f98e836ab737e1b3 Mon Sep 17 00:00:00 2001 From: Evan Borgstrom Date: Wed, 18 Jan 2012 20:40:11 -0500 Subject: [PATCH 68/84] Allow file.sed to utilize regular expressions that are greedy This is a slight change to the logic for detecting an edit that allows for greedy regular expressions. My use case for this is removing ldap from nsswitch.conf. nsswitch_passwd: file: - sed - name: /etc/nsswitch.conf - before: '^passwd:.*' - after: 'passwd: files' Previously `__salt__['file.contains'](name, before, limit)` would return the updated line because the regexp was greedily matching the after line. This meant it would re-apply the edit on every application of the state. --- salt/states/file.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/salt/states/file.py b/salt/states/file.py index 4e0c7e878de9..e5abcb25f426 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -914,14 +914,13 @@ def sed(name, before, after, limit='', backup='.bak', options='-r -e', # to look for ourselves # make sure the pattern(s) match - if not __salt__['file.contains'](name, before, limit): - if __salt__['file.contains'](name, after, limit): - ret['comment'] = "Edit already performed" - ret['result'] = True - return ret - else: - ret['comment'] = "Pattern not matched" - return ret + if __salt__['file.contains'](name, after, limit): + ret['comment'] = "Edit already performed" + ret['result'] = True + return ret + elif not __salt__['file.contains'](name, before, limit): + ret['comment'] = "Pattern not matched" + return ret # should be ok now; perform the edit __salt__['file.sed'](name, before, after, limit, backup, options, flags) From d67c7f561359da774e7419ebfb919025c422d2ff Mon Sep 17 00:00:00 2001 From: Jeff Bauer Date: Wed, 18 Jan 2012 23:04:48 -0600 Subject: [PATCH 69/84] updated documentation for user, fixed configuration template links --- doc/ref/cli/salt-master.rst | 10 ++++++++++ doc/ref/cli/salt-minion.rst | 10 ++++++++++ doc/ref/configuration/examples.rst | 4 ++-- doc/ref/configuration/master.rst | 17 +++++++++++++++-- doc/ref/configuration/minion.rst | 13 +++++++++++++ doc/topics/configuration.rst | 10 ++++++++-- 6 files changed, 58 insertions(+), 6 deletions(-) diff --git a/doc/ref/cli/salt-master.rst b/doc/ref/cli/salt-master.rst index ceb3854600a1..f75ee4e80638 100644 --- a/doc/ref/cli/salt-master.rst +++ b/doc/ref/cli/salt-master.rst @@ -30,3 +30,13 @@ Options .. option:: -c CONFIG, --config=CONFIG The master configuration file to use, the default is /etc/salt/master + +.. option:: -u USER, --user=USER + + Specify user to run minion + +.. option:: -l LOG_LEVEL, --log-level=LOG_LEVEL + + Console log level. One of ``info``, ``none``, ``garbage``, + ``trace``, ``warning``, ``error``, ``debug``. For the logfile + settings see the config file. Default: ``warning``. diff --git a/doc/ref/cli/salt-minion.rst b/doc/ref/cli/salt-minion.rst index 6a9118685cfc..7254566e5d45 100644 --- a/doc/ref/cli/salt-minion.rst +++ b/doc/ref/cli/salt-minion.rst @@ -31,3 +31,13 @@ Options .. option:: -c CONFIG, --config=CONFIG The minion configuration file to use, the default is /etc/salt/minion + +.. option:: -u USER, --user=USER + + Specify user to run minion + +.. option:: -l LOG_LEVEL, --log-level=LOG_LEVEL + + Console log level. One of ``info``, ``none``, ``garbage``, + ``trace``, ``warning``, ``error``, ``debug``. For the logfile + settings see the config file. Default: ``warning``. diff --git a/doc/ref/configuration/examples.rst b/doc/ref/configuration/examples.rst index 70af9194ab4f..04be89d0ce1c 100644 --- a/doc/ref/configuration/examples.rst +++ b/doc/ref/configuration/examples.rst @@ -11,7 +11,7 @@ Configuration file examples Example master configuration file ================================= -.. literalinclude:: ../../../conf/master +.. literalinclude:: ../../../conf/master.template :language: ini :linenos: @@ -20,6 +20,6 @@ Example master configuration file Example minion configuration file ================================= -.. literalinclude:: ../../../conf/minion +.. literalinclude:: ../../../conf/minion.template :language: ini :linenos: diff --git a/doc/ref/configuration/master.rst b/doc/ref/configuration/master.rst index a16a594457ec..0abfdf90e103 100644 --- a/doc/ref/configuration/master.rst +++ b/doc/ref/configuration/master.rst @@ -7,8 +7,8 @@ of the Salt system each have a respective configuration file. The :command:`salt-master` is configured via the master configuration file, and the :command:`salt-minion` is configured via the minion configuration file. -.. seealso:: - :ref:`example master configuration file ` +.. seealso:: + :ref:`example master configuration file ` The configuration file for the salt-master is located at :file:`/etc/salt/master`. The available options are as follows: @@ -42,6 +42,19 @@ The network port to set up the publication interface publish_port: 4505 +.. conf_master:: user + +``user`` +---------------- + +Default: ``root`` + +The user to run the Salt processes + +.. code-block:: yaml + + user: root + .. conf_master:: worker_threads ``worker_threads`` diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst index cfb79de84758..b929743f13cf 100644 --- a/doc/ref/configuration/minion.rst +++ b/doc/ref/configuration/minion.rst @@ -43,6 +43,19 @@ option on the salt master. master_port: 4506 +.. conf_minion:: user + +``user`` +---------------- + +Default: ``root`` + +The user to run the Salt processes + +.. code-block:: yaml + + user: root + .. conf_minion:: pki_dir ``pki_dir`` diff --git a/doc/topics/configuration.rst b/doc/topics/configuration.rst index 1a6682472cc8..732be71b0fd5 100644 --- a/doc/topics/configuration.rst +++ b/doc/topics/configuration.rst @@ -34,12 +34,12 @@ Running Salt 1. Start the master in the foreground (to daemonize the process, pass the :option:`-d flag `):: - salt-master + # salt-master 2. Start the minion in the foreground (to daemonize the process, pass the :option:`-d flag `):: - salt-minion + # salt-minion .. admonition:: Having trouble? @@ -48,6 +48,12 @@ Running Salt salt-master --log-level=debug +.. admonition:: Run as an unprivileged (non-root) user? + + To run Salt as another user, specify ``--user`` in the command + line or assign ``user`` in the + :doc:`configuration file`. + Manage Salt public keys ======================= From 21d757ba73b03bcf488d9d747bfd42fd202ef4fa Mon Sep 17 00:00:00 2001 From: "Colin B." Date: Thu, 19 Jan 2012 14:01:53 -0800 Subject: [PATCH 70/84] Salt is now platform dependent. Use get_python_lib(1) --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5f0d2a7de4aa..4e7316370af2 100755 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ def run(self): VER = __version__ DESC = ('Portable, distributed, remote execution and ' 'configuration management system') -mod_path = os.path.join(get_python_lib(), 'salt/modules') +mod_path = os.path.join(get_python_lib(1), 'salt/modules') doc_path = os.path.join(PREFIX, 'share/doc', NAME + '-' + VER) example_path = os.path.join(doc_path, 'examples') template_path = os.path.join(example_path, 'templates') From 43c60571189c4e4b0fb54e80d4df9292e5c1c535 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Thu, 19 Jan 2012 16:42:29 -0700 Subject: [PATCH 71/84] Add more data to running tag in state compiler - fixes names bug --- salt/state.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/salt/state.py b/salt/state.py index f588e96df5c7..6789fa7c3025 100644 --- a/salt/state.py +++ b/salt/state.py @@ -526,7 +526,7 @@ def call_chunks(self, chunks): if '__FAILHARD__' in running: running.pop('__FAILHARD__') return running - tag = '{0[state]}.{0[__id__]}.{0[fun]}'.format(low) + tag = '{0[state]}.{0[__id__]}.{0[name]}.{0[fun]}'.format(low) if tag not in running: running = self.call_chunk(low, running, chunks) if self.check_failhard(low, running): @@ -537,7 +537,7 @@ def check_failhard(self, low, running): ''' Check if the low data chunk should send a failhard signal ''' - tag = '{0[state]}.{0[__id__]}.{0[fun]}'.format(low) + tag = '{0[state]}.{0[__id__]}.{0[name]}.{0[fun]}'.format(low) if low.get('failhard', False) \ or self.opts['failhard'] \ and tag in running: @@ -561,7 +561,7 @@ def check_requires(self, low, running, chunks): reqs.append(chunk) fun_stats = [] for req in reqs: - tag = '{0[state]}.{0[__id__]}.{0[fun]}'.format(req) + tag = '{0[state]}.{0[__id__]}.{0[name]}.{0[fun]}'.format(req) if tag not in running: fun_stats.append('unmet') else: @@ -589,7 +589,7 @@ def check_watchers(self, low, running, chunks): reqs.append(chunk) fun_stats = [] for req in reqs: - tag = '{0[state]}.{0[__id__]}.{0[fun]}'.format(req) + tag = '{0[state]}.{0[__id__]}.{0[name]}.{0[fun]}'.format(req) if tag not in running: fun_stats.append('unmet') else: @@ -607,7 +607,7 @@ def call_chunk(self, low, running, chunks): Check if a chunk has any requires, execute the requires and then the chunk ''' - tag = '{0[state]}.{0[__id__]}.{0[fun]}'.format(low) + tag = '{0[state]}.{0[__id__]}.{0[name]}.{0[fun]}'.format(low) if 'require' in low: status = self.check_requires(low, running, chunks) if status == 'unmet': From ad3f74c2c7c64ca7534d0d96b27a32015626d01b Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Thu, 19 Jan 2012 16:53:41 -0700 Subject: [PATCH 72/84] update outputter for new data in running tag --- salt/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/output.py b/salt/output.py index b7c13c5c9d10..efd99e57bf1e 100644 --- a/salt/output.py +++ b/salt/output.py @@ -78,7 +78,7 @@ def __call__(self, data, **kwargs): # style above hstrs.append(' {0}Name: {1}{2[ENDC]}'.format( tcolor, - '.'.join(comps[1:-1]), + '.'.join(comps[2:-1]), colors )) hstrs.append(' {0}Function: {1}{2[ENDC]}'.format( From 93423aa2e5e4b7de6452090b0039560d2b1302e4 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 20 Jan 2012 02:17:42 -0600 Subject: [PATCH 73/84] added ability to run a command as another user --- salt/modules/cmd.py | 94 ++++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 27 deletions(-) diff --git a/salt/modules/cmd.py b/salt/modules/cmd.py index c49cea564680..c7d913772dc5 100644 --- a/salt/modules/cmd.py +++ b/salt/modules/cmd.py @@ -10,6 +10,7 @@ import subprocess import tempfile import salt.utils +import pwd # Set up logging log = logging.getLogger(__name__) @@ -26,36 +27,76 @@ def _run(cmd, cwd=DEFAULT_CWD, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - quiet=False): + quiet=False, + runas=None): ''' Do the DRY thing and only call subprocess.Popen() once ''' ret = {} - if not quiet: - log.info('Executing command {0} in directory {1}'.format(cmd, cwd)) - proc = subprocess.Popen(cmd, - cwd=cwd, - shell=True, - stdout=stdout, - stderr=stderr, - ) - out = proc.communicate() - ret['stdout'] = out[0] - ret['stderr'] = out[1] - ret['retcode'] = proc.returncode - ret['pid'] = proc.pid + uid = os.getuid() + euid = os.geteuid() + + def su(): + os.setuid(runas_uid) + os.seteuid(runas_uid) + + if runas: + try: + p = pwd.getpwnam(runas) + except KeyError: + stderr_str = 'The user %s is not available' % runas + if stderr == subprocess.STDOUT: + ret['stdout'] = stderr_str + else: + ret['stdout'] = '' + ret['stderr'] = stderr_str + ret['retcode'] = 1 + return ret + runas_uid = p.pw_uid + preexec = su + else: + preexec = None + if not quiet: + if runas: + log.info('Executing command {0} as user {1} in directory {2}'.format( + cmd, runas, cwd)) + else: + log.info('Executing command {0} in directory {1}'.format(cmd, cwd)) + + try: + proc = subprocess.Popen(cmd, + cwd=cwd, + shell=True, + stdout=stdout, + stderr=stderr, + preexec_fn=preexec + ) + + out = proc.communicate() + ret['stdout'] = out[0] + ret['stderr'] = out[1] + ret['retcode'] = proc.returncode + ret['pid'] = proc.pid + except OSError: + stderr_str = 'Unable to change to user %s: permission denied' % runas + if stderr == subprocess.STDOUT: + ret['stdout'] = stderr_str + else: + ret['stdout'] = '' + ret['stderr'] = stderr_str + ret['retcode'] = 2 return ret -def _run_quiet(cmd, cwd=DEFAULT_CWD): +def _run_quiet(cmd, runas=None, cwd=DEFAULT_CWD): ''' Helper for running commands quietly for minion startup ''' - return _run(cmd, cwd, stderr=subprocess.STDOUT, quiet=True)['stdout'] + return _run(cmd, runas=runas, cwd=cwd, stderr=subprocess.STDOUT, quiet=True)['stdout'] -def run(cmd, cwd=DEFAULT_CWD): +def run(cmd, runas=None, cwd=DEFAULT_CWD): ''' Execute the passed command and return the output as a string @@ -63,12 +104,12 @@ def run(cmd, cwd=DEFAULT_CWD): salt '*' cmd.run "ls -l | awk '/foo/{print $2}'" ''' - out = _run(cmd, cwd=cwd, stderr=subprocess.STDOUT)['stdout'] + out = _run(cmd, runas=runas, cwd=cwd, stderr=subprocess.STDOUT)['stdout'] log.debug(out) return out -def run_stdout(cmd, cwd=DEFAULT_CWD): +def run_stdout(cmd, runas=None, cwd=DEFAULT_CWD): ''' Execute a command, and only return the standard out @@ -76,12 +117,12 @@ def run_stdout(cmd, cwd=DEFAULT_CWD): salt '*' cmd.run_stdout "ls -l | awk '/foo/{print $2}'" ''' - stdout = _run(cmd, cwd=cwd)["stdout"] + stdout = _run(cmd, runas=runas, cwd=cwd)["stdout"] log.debug(stdout) return stdout -def run_stderr(cmd, cwd=DEFAULT_CWD): +def run_stderr(cmd, runas=None, cwd=DEFAULT_CWD): ''' Execute a command and only return the standard error @@ -89,12 +130,12 @@ def run_stderr(cmd, cwd=DEFAULT_CWD): salt '*' cmd.run_stderr "ls -l | awk '/foo/{print $2}'" ''' - stderr = _run(cmd, cwd=cwd)["stderr"] + stderr = _run(cmd, runas=runas, cwd=cwd)["stderr"] log.debug(stderr) return stderr -def run_all(cmd, cwd=DEFAULT_CWD): +def run_all(cmd, runas=None, cwd=DEFAULT_CWD): ''' Execute the passed command and return a dict of return data @@ -102,7 +143,7 @@ def run_all(cmd, cwd=DEFAULT_CWD): salt '*' cmd.run_all "ls -l | awk '/foo/{print $2}'" ''' - ret = _run(cmd, cwd=cwd) + ret = _run(cmd, runas=runas, cwd=cwd) if ret['retcode'] != 0: log.error('Command {0} failed'.format(cmd)) log.error('retcode: {0}'.format(ret['retcode'])) @@ -114,7 +155,7 @@ def run_all(cmd, cwd=DEFAULT_CWD): return ret -def retcode(cmd, cwd=DEFAULT_CWD): +def retcode(cmd, runas=None, cwd=DEFAULT_CWD): ''' Execute a shell command and return the command's return code. @@ -122,8 +163,7 @@ def retcode(cmd, cwd=DEFAULT_CWD): salt '*' cmd.retcode "file /bin/bash" ''' - log.info('Executing command {0} in directory {1}'.format(cmd, cwd)) - return _run(cmd, cwd=cwd)['retcode'] + return _run(cmd, runas=runas, cwd=cwd)['retcode'] def has_exec(cmd): From 2262db9468cf47d077e3f9a2be07f31d5bbab303 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 20 Jan 2012 04:49:22 -0600 Subject: [PATCH 74/84] updated to reflect changes in commit 93423aa2e5e4b7de6452090b0039560d2b1302e4 --- doc/man/salt.7 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/man/salt.7 b/doc/man/salt.7 index cfc3da627819..02c10a146df9 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -2200,8 +2200,8 @@ salt \(aq*\(aq cmd.has_exec cat .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.retcode(cmd, cwd=\(aq/home/thatch\(aq) -Execute a shell command and return the command\(aqs return code. +.B salt.modules.cmd.retcode(cmd, runas=None, cwd=\(aq/home/thatch\(aq) +Execute a shell command and return the command\(aqs return code .sp CLI Example: .sp @@ -2213,7 +2213,7 @@ salt \(aq*\(aq cmd.retcode "file /bin/bash" .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.run(cmd, cwd=\(aq/home/thatch\(aq) +.B salt.modules.cmd.run(cmd, runas=None, cwd=\(aq/home/thatch\(aq) Execute the passed command and return the output as a string .sp CLI Example: @@ -2226,7 +2226,7 @@ salt \(aq*\(aq cmd.run "ls \-l | awk \(aq/foo/{print $2}\(aq" .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.run_all(cmd, cwd=\(aq/home/thatch\(aq) +.B salt.modules.cmd.run_all(cmd, runas=None, cwd=\(aq/home/thatch\(aq) Execute the passed command and return a dict of return data .sp CLI Example: @@ -2239,7 +2239,7 @@ salt \(aq*\(aq cmd.run_all "ls \-l | awk \(aq/foo/{print $2}\(aq" .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.run_stderr(cmd, cwd=\(aq/home/thatch\(aq) +.B salt.modules.cmd.run_stderr(cmd, runas=None, cwd=\(aq/home/thatch\(aq) Execute a command and only return the standard error .sp CLI Example: @@ -2252,7 +2252,7 @@ salt \(aq*\(aq cmd.run_stderr "ls \-l | awk \(aq/foo/{print $2}\(aq" .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.run_stdout(cmd, cwd=\(aq/home/thatch\(aq) +.B salt.modules.cmd.run_stdout(cmd, runas=None, cwd=\(aq/home/thatch\(aq) Execute a command, and only return the standard out .sp CLI Example: From 22894b373b0765fe2a042d42ceff78792695c3c9 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 09:37:46 -0700 Subject: [PATCH 75/84] remove cytest from setup.py --- setup.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.py b/setup.py index 4e7316370af2..bd1b8b74b546 100755 --- a/setup.py +++ b/setup.py @@ -138,9 +138,6 @@ def __init__(self, *args, **kwargs): ('share/man/man7', ['doc/man/salt.7', ]), - (mod_path, - ['salt/modules/cytest.pyx', - ]), (doc_path, [ ]), From 532d868fa50e9813773dc6d3dd8ec1105834a42d Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 10:22:21 -0700 Subject: [PATCH 76/84] add docs files to the tarball --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bd1b8b74b546..491c0dba0405 100755 --- a/setup.py +++ b/setup.py @@ -139,7 +139,9 @@ def __init__(self, *args, **kwargs): ['doc/man/salt.7', ]), (doc_path, - [ + ['LICENSE', + 'AUTHORS', + 'README.rst', ]), ], ) From a1d672cdcbb203a931e943f4ec109bcc42223fe7 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 10:45:37 -0700 Subject: [PATCH 77/84] Set up extension_modules opts before loading grains --- salt/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/config.py b/salt/config.py index c3b7deb2d1ab..ef2f4ee283e8 100644 --- a/salt/config.py +++ b/salt/config.py @@ -116,14 +116,14 @@ def minion_config(path): # else! opts['open_mode'] = opts['open_mode'] is True + # set up the extension_modules location from the cachedir + opts['extension_modules'] = os.path.join(opts['cachedir'], 'extmods') + opts['grains'] = salt.loader.grains(opts) # Prepend root_dir to other paths prepend_root_dir(opts, ['pki_dir', 'cachedir', 'log_file']) - # set up the extension_modules location from the cachedir - opts['extension_modules'] = os.path.join(opts['cachedir'], 'extmods') - return opts From 6eb94f9914db2ae536011fb633e3f99658c8c73d Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 10:48:11 -0700 Subject: [PATCH 78/84] look for extension grains --- salt/loader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/salt/loader.py b/salt/loader.py index 0a2ab46c635f..ad50f4d2d38e 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -100,9 +100,13 @@ def grains(opts): Return the functions for the dynamic grains and the values for the static grains. ''' + extra_dirs = [ + os.path.join(opts['extension_modules'], + 'grains') + ] module_dirs = [ os.path.join(salt_base_path, 'grains'), - ] + ] + extra_dirs load = Loader(module_dirs, opts) grains = load.gen_grains() if 'grains' in opts: From 77a66402bbbffb71299bd4d38026880de245c19c Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 11:25:16 -0700 Subject: [PATCH 79/84] move runas to the last arg --- salt/modules/cmd.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/salt/modules/cmd.py b/salt/modules/cmd.py index c7d913772dc5..de30ce2f7b8a 100644 --- a/salt/modules/cmd.py +++ b/salt/modules/cmd.py @@ -44,7 +44,7 @@ def su(): try: p = pwd.getpwnam(runas) except KeyError: - stderr_str = 'The user %s is not available' % runas + stderr_str = 'The user {0} is not available'.format(runas) if stderr == subprocess.STDOUT: ret['stdout'] = stderr_str else: @@ -79,7 +79,7 @@ def su(): ret['retcode'] = proc.returncode ret['pid'] = proc.pid except OSError: - stderr_str = 'Unable to change to user %s: permission denied' % runas + stderr_str = 'Unable to change to user {0}: permission denied'.format(runas) if stderr == subprocess.STDOUT: ret['stdout'] = stderr_str else: @@ -89,14 +89,14 @@ def su(): return ret -def _run_quiet(cmd, runas=None, cwd=DEFAULT_CWD): +def _run_quiet(cmd, cwd=DEFAULT_CWD, runas=None): ''' Helper for running commands quietly for minion startup ''' return _run(cmd, runas=runas, cwd=cwd, stderr=subprocess.STDOUT, quiet=True)['stdout'] -def run(cmd, runas=None, cwd=DEFAULT_CWD): +def run(cmd, cwd=DEFAULT_CWD, runas=None): ''' Execute the passed command and return the output as a string @@ -109,7 +109,7 @@ def run(cmd, runas=None, cwd=DEFAULT_CWD): return out -def run_stdout(cmd, runas=None, cwd=DEFAULT_CWD): +def run_stdout(cmd, cwd=DEFAULT_CWD, runas=None): ''' Execute a command, and only return the standard out @@ -122,7 +122,7 @@ def run_stdout(cmd, runas=None, cwd=DEFAULT_CWD): return stdout -def run_stderr(cmd, runas=None, cwd=DEFAULT_CWD): +def run_stderr(cmd, cwd=DEFAULT_CWD, runas=None): ''' Execute a command and only return the standard error @@ -135,7 +135,7 @@ def run_stderr(cmd, runas=None, cwd=DEFAULT_CWD): return stderr -def run_all(cmd, runas=None, cwd=DEFAULT_CWD): +def run_all(cmd, cwd=DEFAULT_CWD, runas=None): ''' Execute the passed command and return a dict of return data @@ -155,7 +155,7 @@ def run_all(cmd, runas=None, cwd=DEFAULT_CWD): return ret -def retcode(cmd, runas=None, cwd=DEFAULT_CWD): +def retcode(cmd, cwd=DEFAULT_CWD, runas=None): ''' Execute a shell command and return the command's return code. From 7b16bc18be60d0f631aecd650b459dc32de51bad Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 19:30:57 -0700 Subject: [PATCH 80/84] take msgpack out of the setup.py --- MANIFEST.in | 4 +++- requirements.txt | 6 ++++++ setup.py | 38 +------------------------------------- 3 files changed, 10 insertions(+), 38 deletions(-) create mode 100644 requirements.txt diff --git a/MANIFEST.in b/MANIFEST.in index 81c035d98553..7c985df0444a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,3 @@ -include salt/msgpack/*.h +include AUTHORS +include LICENSE +include README.rst diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000000..08bfd0d20e4f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +Jinja2 +pyzmq +msgpack-python +M2Crypto +pycrypto +PyYAML diff --git a/setup.py b/setup.py index 491c0dba0405..3c9fb691ba6d 100755 --- a/setup.py +++ b/setup.py @@ -32,15 +32,6 @@ def run(self): ) test_process.communicate() -try: - from Cython.Distutils import build_ext - import Cython.Compiler.Main as cython_compiler - have_cython = True -except ImportError: - from distutils.command.build_ext import build_ext - have_cython = False - - NAME = 'salt' VER = __version__ DESC = ('Portable, distributed, remote execution and ' @@ -55,28 +46,8 @@ def run(self): else: etc_path = os.path.join(os.path.dirname(PREFIX), 'etc') -# take care of extension modules. -if have_cython: - sources = ['salt/msgpack/_msgpack.pyx'] - - class Sdist(sdist): - def __init__(self, *args, **kwargs): - for src in glob('salt/msgpack/*.pyx'): - cython_compiler.compile(glob('msgpack/*.pyx'), - cython_compiler.default_options) - sdist.__init__(self, *args, **kwargs) -else: - sources = ['salt/msgpack/_msgpack.c'] - - Sdist = sdist - libraries = ['ws2_32'] if sys.platform == 'win32' else [] -msgpack_mod = Extension('salt.msgpack._msgpack', - sources=sources, - libraries=libraries, - ) - setup( name=NAME, version=VER, @@ -84,8 +55,7 @@ def __init__(self, *args, **kwargs): author='Thomas S Hatch', author_email='thatch45@gmail.com', url='http://saltstack.org', - ext_modules=[msgpack_mod], - cmdclass={'build_ext': build_ext, 'sdist': Sdist, 'test': TestCommand}, + cmdclass={'test': TestCommand}, classifiers=[ 'Programming Language :: Python', 'Programming Language :: Cython', @@ -111,7 +81,6 @@ def __init__(self, *args, **kwargs): 'salt.runners', 'salt.states', 'salt.utils', - 'salt.msgpack', ], scripts=['scripts/salt-master', 'scripts/salt-minion', @@ -138,10 +107,5 @@ def __init__(self, *args, **kwargs): ('share/man/man7', ['doc/man/salt.7', ]), - (doc_path, - ['LICENSE', - 'AUTHORS', - 'README.rst', - ]), ], ) From c7bb2d032157129db9d03e77a8aca642a3fa50ac Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 19:36:53 -0700 Subject: [PATCH 81/84] take out the bundled msgpack --- salt/msgpack/__init__.py | 20 - salt/msgpack/__version__.py | 1 - salt/msgpack/_msgpack.c | 6762 -------------------------------- salt/msgpack/_msgpack.pyx | 427 -- salt/msgpack/pack.h | 107 - salt/msgpack/pack_define.h | 25 - salt/msgpack/pack_template.h | 686 ---- salt/msgpack/sysdep.h | 94 - salt/msgpack/unpack.h | 213 - salt/msgpack/unpack_define.h | 92 - salt/msgpack/unpack_template.h | 386 -- salt/payload.py | 2 +- 12 files changed, 1 insertion(+), 8814 deletions(-) delete mode 100644 salt/msgpack/__init__.py delete mode 100644 salt/msgpack/__version__.py delete mode 100644 salt/msgpack/_msgpack.c delete mode 100644 salt/msgpack/_msgpack.pyx delete mode 100644 salt/msgpack/pack.h delete mode 100644 salt/msgpack/pack_define.h delete mode 100644 salt/msgpack/pack_template.h delete mode 100644 salt/msgpack/sysdep.h delete mode 100644 salt/msgpack/unpack.h delete mode 100644 salt/msgpack/unpack_define.h delete mode 100644 salt/msgpack/unpack_template.h diff --git a/salt/msgpack/__init__.py b/salt/msgpack/__init__.py deleted file mode 100644 index f68bf6e640e7..000000000000 --- a/salt/msgpack/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# coding: utf-8 -from salt.msgpack.__version__ import version -from salt.msgpack._msgpack import unpack, unpackb, pack, packb - -# alias for compatibility to simplejson/marshal/pickle. -load = unpack -loads = unpackb - -dump = pack -dumps = packb - -def packs(*args, **kw): - from warnings import warn - warn("msgpack.packs() is deprecated. Use packb() instead.", DeprecationWarning) - return packb(*args, **kw) - -def unpacks(*args, **kw): - from warnings import warn - warn("msgpack.unpacks() is deprecated. Use unpackb() instead.", DeprecationWarning) - return unpackb(*args, **kw) diff --git a/salt/msgpack/__version__.py b/salt/msgpack/__version__.py deleted file mode 100644 index 84e88e8c4972..000000000000 --- a/salt/msgpack/__version__.py +++ /dev/null @@ -1 +0,0 @@ -version = (0, 1, 12) diff --git a/salt/msgpack/_msgpack.c b/salt/msgpack/_msgpack.c deleted file mode 100644 index b6fe3201540f..000000000000 --- a/salt/msgpack/_msgpack.c +++ /dev/null @@ -1,6762 +0,0 @@ -/* Generated by Cython 0.15.1 on Tue Dec 27 21:35:07 2011 */ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#else - -#include /* For offsetof */ -#ifndef offsetof -#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif - -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif - -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif - -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif - -#if PY_VERSION_HEX < 0x02040000 - #define METH_COEXIST 0 - #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) - #define PyDict_Contains(d,o) PySequence_Contains(d,o) -#endif - -#if PY_VERSION_HEX < 0x02050000 - typedef int Py_ssize_t; - #define PY_SSIZE_T_MAX INT_MAX - #define PY_SSIZE_T_MIN INT_MIN - #define PY_FORMAT_SIZE_T "" - #define PyInt_FromSsize_t(z) PyInt_FromLong(z) - #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) - #define PyNumber_Index(o) PyNumber_Int(o) - #define PyIndex_Check(o) PyNumber_Check(o) - #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message) -#endif - -#if PY_VERSION_HEX < 0x02060000 - #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) - #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) - #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) - #define PyVarObject_HEAD_INIT(type, size) \ - PyObject_HEAD_INIT(type) size, - #define PyType_Modified(t) - - typedef struct { - void *buf; - PyObject *obj; - Py_ssize_t len; - Py_ssize_t itemsize; - int readonly; - int ndim; - char *format; - Py_ssize_t *shape; - Py_ssize_t *strides; - Py_ssize_t *suboffsets; - void *internal; - } Py_buffer; - - #define PyBUF_SIMPLE 0 - #define PyBUF_WRITABLE 0x0001 - #define PyBUF_FORMAT 0x0004 - #define PyBUF_ND 0x0008 - #define PyBUF_STRIDES (0x0010 | PyBUF_ND) - #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) - #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) - #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) - #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) - -#endif - -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" -#endif - -#if PY_MAJOR_VERSION >= 3 - #define Py_TPFLAGS_CHECKTYPES 0 - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif - -#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif - -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#endif - -#if PY_VERSION_HEX < 0x02060000 - #define PyBytesObject PyStringObject - #define PyBytes_Type PyString_Type - #define PyBytes_Check PyString_Check - #define PyBytes_CheckExact PyString_CheckExact - #define PyBytes_FromString PyString_FromString - #define PyBytes_FromStringAndSize PyString_FromStringAndSize - #define PyBytes_FromFormat PyString_FromFormat - #define PyBytes_DecodeEscape PyString_DecodeEscape - #define PyBytes_AsString PyString_AsString - #define PyBytes_AsStringAndSize PyString_AsStringAndSize - #define PyBytes_Size PyString_Size - #define PyBytes_AS_STRING PyString_AS_STRING - #define PyBytes_GET_SIZE PyString_GET_SIZE - #define PyBytes_Repr PyString_Repr - #define PyBytes_Concat PyString_Concat - #define PyBytes_ConcatAndDel PyString_ConcatAndDel -#endif - -#if PY_VERSION_HEX < 0x02060000 - #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) - #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif - -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) - -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask -#endif - -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif - -#if PY_VERSION_HEX < 0x03020000 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif - - -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - -#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) - #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) - #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) - #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b) -#else - #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0))) - #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1))) - #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \ - (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \ - (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ - (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) -#endif - -#if PY_MAJOR_VERSION >= 3 - #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) -#endif - -#if PY_VERSION_HEX < 0x02050000 - #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) - #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) - #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n))) -#else - #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n)) - #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) - #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) -#endif - -#if PY_VERSION_HEX < 0x02050000 - #define __Pyx_NAMESTR(n) ((char *)(n)) - #define __Pyx_DOCSTR(n) ((char *)(n)) -#else - #define __Pyx_NAMESTR(n) (n) - #define __Pyx_DOCSTR(n) (n) -#endif - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#if defined(WIN32) || defined(MS_WINDOWS) -#define _USE_MATH_DEFINES -#endif -#include -#define __PYX_HAVE__msgpack___msgpack -#define __PYX_HAVE_API__msgpack___msgpack -#include "stdio.h" -#include "pythread.h" -#include "stdlib.h" -#include "string.h" -#include "pack.h" -#include "unpack.h" -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#ifdef PYREX_WITHOUT_ASSERTIONS -#define CYTHON_WITHOUT_ASSERTIONS -#endif - - -/* inline attribute */ -#ifndef CYTHON_INLINE - #if defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif - -/* unused attribute */ -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || defined(__INTEL_COMPILER) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif - -typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/ - - -/* Type Conversion Predeclarations */ - -#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s) -#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s)) - -#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); - -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*); - -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) - - -#ifdef __GNUC__ - /* Test for GCC > 2.95 */ - #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) - #else /* __GNUC__ > 2 ... */ - #define likely(x) (x) - #define unlikely(x) (x) - #endif /* __GNUC__ > 2 ... */ -#else /* __GNUC__ */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ - -static PyObject *__pyx_m; -static PyObject *__pyx_b; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - - -static const char *__pyx_f[] = { - "_msgpack.pyx", - "bool.pxd", - "complex.pxd", -}; - -/*--- Type declarations ---*/ -struct __pyx_obj_7msgpack_8_msgpack_Unpacker; -struct __pyx_obj_7msgpack_8_msgpack_Packer; -struct __pyx_opt_args_7msgpack_8_msgpack_6Packer__pack; - -/* "msgpack/_msgpack.pyx":85 - * free(self.pk.buf); - * - * cdef int _pack(self, object o, int nest_limit=DEFAULT_RECURSE_LIMIT) except -1: # <<<<<<<<<<<<<< - * cdef long long llval - * cdef unsigned long long ullval - */ -struct __pyx_opt_args_7msgpack_8_msgpack_6Packer__pack { - int __pyx_n; - int nest_limit; -}; - -/* "msgpack/_msgpack.pyx":253 - * object_hook=object_hook, list_hook=list_hook, encoding=encoding, unicode_errors=unicode_errors) - * - * cdef class Unpacker(object): # <<<<<<<<<<<<<< - * """ - * Streaming unpacker. - */ -struct __pyx_obj_7msgpack_8_msgpack_Unpacker { - PyObject_HEAD - struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker *__pyx_vtab; - template_context ctx; - char *buf; - size_t buf_size; - size_t buf_head; - size_t buf_tail; - PyObject *file_like; - PyObject *file_like_read; - Py_ssize_t read_size; - int use_list; - PyObject *object_hook; - PyObject *_bencoding; - PyObject *_berrors; - char *encoding; - char *unicode_errors; -}; - - -/* "msgpack/_msgpack.pyx":38 - * cdef int DEFAULT_RECURSE_LIMIT=511 - * - * cdef class Packer(object): # <<<<<<<<<<<<<< - * """MessagePack Packer - * - */ -struct __pyx_obj_7msgpack_8_msgpack_Packer { - PyObject_HEAD - struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer *__pyx_vtab; - struct msgpack_packer pk; - PyObject *_default; - PyObject *_bencoding; - PyObject *_berrors; - char *encoding; - char *unicode_errors; -}; - - - -/* "msgpack/_msgpack.pyx":253 - * object_hook=object_hook, list_hook=list_hook, encoding=encoding, unicode_errors=unicode_errors) - * - * cdef class Unpacker(object): # <<<<<<<<<<<<<< - * """ - * Streaming unpacker. - */ - -struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker { - PyObject *(*append_buffer)(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *, void *, Py_ssize_t); - PyObject *(*fill_buffer)(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *); - PyObject *(*unpack)(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker *__pyx_vtabptr_7msgpack_8_msgpack_Unpacker; - - -/* "msgpack/_msgpack.pyx":38 - * cdef int DEFAULT_RECURSE_LIMIT=511 - * - * cdef class Packer(object): # <<<<<<<<<<<<<< - * """MessagePack Packer - * - */ - -struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer { - int (*_pack)(struct __pyx_obj_7msgpack_8_msgpack_Packer *, PyObject *, struct __pyx_opt_args_7msgpack_8_msgpack_6Packer__pack *__pyx_optional_args); -}; -static struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer *__pyx_vtabptr_7msgpack_8_msgpack_Packer; - -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif - -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/ - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; - #define __Pyx_RefNannySetupContext(name) __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) - #define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif /* CYTHON_REFNANNY */ - -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ - -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/ - -static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, - const char* function_name, int kw_allowed); /*proto*/ - -static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ -static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ - -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/ - -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, PyObject* kw_name); /*proto*/ - -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/ - -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ - -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/ - -static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); - -static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); - -static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *); - -static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *); - -static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *); - -static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *); - -static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *); - -static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *); - -static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *); - -static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *); - -static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *); - -static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *); - -static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *); - -static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *); - -static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); - -static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); - -static int __Pyx_check_binary_version(void); - -static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ - -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ - -static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ - -static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno, - int __pyx_lineno, const char *__pyx_filename); /*proto*/ - -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ - -/* Module declarations from 'cpython.version' */ - -/* Module declarations from 'cpython.ref' */ - -/* Module declarations from 'cpython.exc' */ - -/* Module declarations from 'cpython.module' */ - -/* Module declarations from 'cpython.mem' */ - -/* Module declarations from 'cpython.tuple' */ - -/* Module declarations from 'cpython.list' */ - -/* Module declarations from 'libc.stdio' */ - -/* Module declarations from 'cpython.object' */ - -/* Module declarations from 'cpython.sequence' */ - -/* Module declarations from 'cpython.mapping' */ - -/* Module declarations from 'cpython.iterator' */ - -/* Module declarations from 'cpython.type' */ - -/* Module declarations from 'cpython.number' */ - -/* Module declarations from 'cpython.int' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.bool' */ -static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0; - -/* Module declarations from 'cpython.long' */ - -/* Module declarations from 'cpython.float' */ - -/* Module declarations from '__builtin__' */ - -/* Module declarations from 'cpython.complex' */ -static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0; - -/* Module declarations from 'cpython.string' */ - -/* Module declarations from 'cpython.unicode' */ - -/* Module declarations from 'cpython.dict' */ - -/* Module declarations from 'cpython.instance' */ - -/* Module declarations from 'cpython.function' */ - -/* Module declarations from 'cpython.method' */ - -/* Module declarations from 'cpython.weakref' */ - -/* Module declarations from 'cpython.getargs' */ - -/* Module declarations from 'cpython.pythread' */ - -/* Module declarations from 'cpython.pystate' */ - -/* Module declarations from 'cpython.cobject' */ - -/* Module declarations from 'cpython.oldbuffer' */ - -/* Module declarations from 'cpython.set' */ - -/* Module declarations from 'cpython.buffer' */ - -/* Module declarations from 'cpython.bytes' */ - -/* Module declarations from 'cpython.pycapsule' */ - -/* Module declarations from 'cpython' */ - -/* Module declarations from 'libc.stdlib' */ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'msgpack._msgpack' */ -static PyTypeObject *__pyx_ptype_7msgpack_8_msgpack_Packer = 0; -static PyTypeObject *__pyx_ptype_7msgpack_8_msgpack_Unpacker = 0; -static int __pyx_v_7msgpack_8_msgpack_DEFAULT_RECURSE_LIMIT; -#define __Pyx_MODULE_NAME "msgpack._msgpack" -int __pyx_module_is_main_msgpack___msgpack = 0; - -/* Implementation of 'msgpack._msgpack' */ -static PyObject *__pyx_builtin_MemoryError; -static PyObject *__pyx_builtin_TypeError; -static PyObject *__pyx_builtin_ValueError; -static PyObject *__pyx_builtin_AssertionError; -static PyObject *__pyx_builtin_StopIteration; -static char __pyx_k_1[] = "Unable to allocate internal buffer."; -static char __pyx_k_3[] = "utf-8"; -static char __pyx_k_4[] = "default must be a callable."; -static char __pyx_k_9[] = "Too deep."; -static char __pyx_k_11[] = "Can't encode utf-8 no encoding is specified"; -static char __pyx_k_13[] = "can't serialize %r"; -static char __pyx_k_16[] = "object_hook must be a callable."; -static char __pyx_k_18[] = "list_hook must be a callable."; -static char __pyx_k_20[] = "`file_like.read` must be a callable."; -static char __pyx_k_27[] = "unpacker.feed() is not be able to use with`file_like`."; -static char __pyx_k_29[] = "Unable to enlarge internal buffer."; -static char __pyx_k_31[] = "No more unpack data."; -static char __pyx_k_33[] = "Unpack failed: error = %d"; -static char __pyx_k_34[] = "msgpack._msgpack"; -static char __pyx_k__o[] = "o"; -static char __pyx_k__gc[] = "gc"; -static char __pyx_k__pack[] = "pack"; -static char __pyx_k__read[] = "read"; -static char __pyx_k__ascii[] = "ascii"; -static char __pyx_k__packb[] = "packb"; -static char __pyx_k__write[] = "write"; -static char __pyx_k__enable[] = "enable"; -static char __pyx_k__encode[] = "encode"; -static char __pyx_k__packed[] = "packed"; -static char __pyx_k__stream[] = "stream"; -static char __pyx_k__strict[] = "strict"; -static char __pyx_k__unpack[] = "unpack"; -static char __pyx_k__default[] = "default"; -static char __pyx_k__disable[] = "disable"; -static char __pyx_k__unpackb[] = "unpackb"; -static char __pyx_k____main__[] = "__main__"; -static char __pyx_k____test__[] = "__test__"; -static char __pyx_k__encoding[] = "encoding"; -static char __pyx_k__use_list[] = "use_list"; -static char __pyx_k__TypeError[] = "TypeError"; -static char __pyx_k__file_like[] = "file_like"; -static char __pyx_k__list_hook[] = "list_hook"; -static char __pyx_k__read_size[] = "read_size"; -static char __pyx_k__ValueError[] = "ValueError"; -static char __pyx_k___gc_enable[] = "_gc_enable"; -static char __pyx_k__MemoryError[] = "MemoryError"; -static char __pyx_k___gc_disable[] = "_gc_disable"; -static char __pyx_k__object_hook[] = "object_hook"; -static char __pyx_k__StopIteration[] = "StopIteration"; -static char __pyx_k__AssertionError[] = "AssertionError"; -static char __pyx_k__unicode_errors[] = "unicode_errors"; -static PyObject *__pyx_kp_s_1; -static PyObject *__pyx_kp_s_11; -static PyObject *__pyx_kp_s_13; -static PyObject *__pyx_kp_s_16; -static PyObject *__pyx_kp_s_18; -static PyObject *__pyx_kp_s_20; -static PyObject *__pyx_kp_s_27; -static PyObject *__pyx_kp_s_29; -static PyObject *__pyx_kp_s_3; -static PyObject *__pyx_kp_s_31; -static PyObject *__pyx_kp_s_33; -static PyObject *__pyx_n_s_34; -static PyObject *__pyx_kp_s_4; -static PyObject *__pyx_kp_s_9; -static PyObject *__pyx_n_s__AssertionError; -static PyObject *__pyx_n_s__MemoryError; -static PyObject *__pyx_n_s__StopIteration; -static PyObject *__pyx_n_s__TypeError; -static PyObject *__pyx_n_s__ValueError; -static PyObject *__pyx_n_s____main__; -static PyObject *__pyx_n_s____test__; -static PyObject *__pyx_n_s___gc_disable; -static PyObject *__pyx_n_s___gc_enable; -static PyObject *__pyx_n_s__ascii; -static PyObject *__pyx_n_s__default; -static PyObject *__pyx_n_s__disable; -static PyObject *__pyx_n_s__enable; -static PyObject *__pyx_n_s__encode; -static PyObject *__pyx_n_s__encoding; -static PyObject *__pyx_n_s__file_like; -static PyObject *__pyx_n_s__gc; -static PyObject *__pyx_n_s__list_hook; -static PyObject *__pyx_n_s__o; -static PyObject *__pyx_n_s__object_hook; -static PyObject *__pyx_n_s__pack; -static PyObject *__pyx_n_s__packb; -static PyObject *__pyx_n_s__packed; -static PyObject *__pyx_n_s__read; -static PyObject *__pyx_n_s__read_size; -static PyObject *__pyx_n_s__stream; -static PyObject *__pyx_n_s__strict; -static PyObject *__pyx_n_s__unicode_errors; -static PyObject *__pyx_n_s__unpack; -static PyObject *__pyx_n_s__unpackb; -static PyObject *__pyx_n_s__use_list; -static PyObject *__pyx_n_s__write; -static PyObject *__pyx_int_0; -static int __pyx_k_8; -static PyObject *__pyx_k_tuple_2; -static PyObject *__pyx_k_tuple_5; -static PyObject *__pyx_k_tuple_6; -static PyObject *__pyx_k_tuple_7; -static PyObject *__pyx_k_tuple_10; -static PyObject *__pyx_k_tuple_12; -static PyObject *__pyx_k_tuple_14; -static PyObject *__pyx_k_tuple_15; -static PyObject *__pyx_k_tuple_17; -static PyObject *__pyx_k_tuple_19; -static PyObject *__pyx_k_tuple_21; -static PyObject *__pyx_k_tuple_22; -static PyObject *__pyx_k_tuple_23; -static PyObject *__pyx_k_tuple_24; -static PyObject *__pyx_k_tuple_25; -static PyObject *__pyx_k_tuple_26; -static PyObject *__pyx_k_tuple_28; -static PyObject *__pyx_k_tuple_30; -static PyObject *__pyx_k_tuple_32; - -/* "msgpack/_msgpack.pyx":54 - * cdef char *unicode_errors - * - * def __cinit__(self): # <<<<<<<<<<<<<< - * cdef int buf_size = 1024*1024 - * self.pk.buf = malloc(buf_size); - */ - -static int __pyx_pf_7msgpack_8_msgpack_6Packer___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pf_7msgpack_8_msgpack_6Packer___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_v_buf_size; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__"); - if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; - - /* "msgpack/_msgpack.pyx":55 - * - * def __cinit__(self): - * cdef int buf_size = 1024*1024 # <<<<<<<<<<<<<< - * self.pk.buf = malloc(buf_size); - * if self.pk.buf == NULL: - */ - __pyx_v_buf_size = 1048576; - - /* "msgpack/_msgpack.pyx":56 - * def __cinit__(self): - * cdef int buf_size = 1024*1024 - * self.pk.buf = malloc(buf_size); # <<<<<<<<<<<<<< - * if self.pk.buf == NULL: - * raise MemoryError("Unable to allocate internal buffer.") - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->pk.buf = ((char *)malloc(__pyx_v_buf_size)); - - /* "msgpack/_msgpack.pyx":57 - * cdef int buf_size = 1024*1024 - * self.pk.buf = malloc(buf_size); - * if self.pk.buf == NULL: # <<<<<<<<<<<<<< - * raise MemoryError("Unable to allocate internal buffer.") - * self.pk.buf_size = buf_size - */ - __pyx_t_1 = (((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->pk.buf == NULL); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":58 - * self.pk.buf = malloc(buf_size); - * if self.pk.buf == NULL: - * raise MemoryError("Unable to allocate internal buffer.") # <<<<<<<<<<<<<< - * self.pk.buf_size = buf_size - * self.pk.length = 0 - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L5; - } - __pyx_L5:; - - /* "msgpack/_msgpack.pyx":59 - * if self.pk.buf == NULL: - * raise MemoryError("Unable to allocate internal buffer.") - * self.pk.buf_size = buf_size # <<<<<<<<<<<<<< - * self.pk.length = 0 - * - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->pk.buf_size = __pyx_v_buf_size; - - /* "msgpack/_msgpack.pyx":60 - * raise MemoryError("Unable to allocate internal buffer.") - * self.pk.buf_size = buf_size - * self.pk.length = 0 # <<<<<<<<<<<<<< - * - * def __init__(self, default=None, encoding='utf-8', unicode_errors='strict'): - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->pk.length = 0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("msgpack._msgpack.Packer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":62 - * self.pk.length = 0 - * - * def __init__(self, default=None, encoding='utf-8', unicode_errors='strict'): # <<<<<<<<<<<<<< - * if default is not None: - * if not PyCallable_Check(default): - */ - -static int __pyx_pf_7msgpack_8_msgpack_6Packer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pf_7msgpack_8_msgpack_6Packer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_default = 0; - PyObject *__pyx_v_encoding = 0; - PyObject *__pyx_v_unicode_errors = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - char *__pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__default,&__pyx_n_s__encoding,&__pyx_n_s__unicode_errors,0}; - __Pyx_RefNannySetupContext("__init__"); - { - PyObject* values[3] = {0,0,0}; - values[0] = ((PyObject *)Py_None); - values[1] = ((PyObject *)__pyx_kp_s_3); - values[2] = ((PyObject *)__pyx_n_s__strict); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__default); - if (value) { values[0] = value; kw_args--; } - } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unicode_errors); - if (value) { values[2] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_default = values[0]; - __pyx_v_encoding = values[1]; - __pyx_v_unicode_errors = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("msgpack._msgpack.Packer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - - /* "msgpack/_msgpack.pyx":63 - * - * def __init__(self, default=None, encoding='utf-8', unicode_errors='strict'): - * if default is not None: # <<<<<<<<<<<<<< - * if not PyCallable_Check(default): - * raise TypeError("default must be a callable.") - */ - __pyx_t_1 = (__pyx_v_default != Py_None); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":64 - * def __init__(self, default=None, encoding='utf-8', unicode_errors='strict'): - * if default is not None: - * if not PyCallable_Check(default): # <<<<<<<<<<<<<< - * raise TypeError("default must be a callable.") - * self._default = default - */ - __pyx_t_1 = (!PyCallable_Check(__pyx_v_default)); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":65 - * if default is not None: - * if not PyCallable_Check(default): - * raise TypeError("default must be a callable.") # <<<<<<<<<<<<<< - * self._default = default - * if encoding is None: - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; - } - __pyx_L7:; - goto __pyx_L6; - } - __pyx_L6:; - - /* "msgpack/_msgpack.pyx":66 - * if not PyCallable_Check(default): - * raise TypeError("default must be a callable.") - * self._default = default # <<<<<<<<<<<<<< - * if encoding is None: - * self.encoding = NULL - */ - __Pyx_INCREF(__pyx_v_default); - __Pyx_GIVEREF(__pyx_v_default); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_default); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_default); - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_default = __pyx_v_default; - - /* "msgpack/_msgpack.pyx":67 - * raise TypeError("default must be a callable.") - * self._default = default - * if encoding is None: # <<<<<<<<<<<<<< - * self.encoding = NULL - * self.unicode_errors = NULL - */ - __pyx_t_1 = (__pyx_v_encoding == Py_None); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":68 - * self._default = default - * if encoding is None: - * self.encoding = NULL # <<<<<<<<<<<<<< - * self.unicode_errors = NULL - * else: - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->encoding = NULL; - - /* "msgpack/_msgpack.pyx":69 - * if encoding is None: - * self.encoding = NULL - * self.unicode_errors = NULL # <<<<<<<<<<<<<< - * else: - * if isinstance(encoding, unicode): - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->unicode_errors = NULL; - goto __pyx_L8; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":71 - * self.unicode_errors = NULL - * else: - * if isinstance(encoding, unicode): # <<<<<<<<<<<<<< - * self._bencoding = encoding.encode('ascii') - * else: - */ - __pyx_t_2 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_encoding, __pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":72 - * else: - * if isinstance(encoding, unicode): - * self._bencoding = encoding.encode('ascii') # <<<<<<<<<<<<<< - * else: - * self._bencoding = encoding - */ - __pyx_t_2 = PyObject_GetAttr(__pyx_v_encoding, __pyx_n_s__encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_3); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_bencoding); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_bencoding); - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_bencoding = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L9; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":74 - * self._bencoding = encoding.encode('ascii') - * else: - * self._bencoding = encoding # <<<<<<<<<<<<<< - * self.encoding = PyBytes_AsString(self._bencoding) - * if isinstance(unicode_errors, unicode): - */ - __Pyx_INCREF(__pyx_v_encoding); - __Pyx_GIVEREF(__pyx_v_encoding); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_bencoding); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_bencoding); - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_bencoding = __pyx_v_encoding; - } - __pyx_L9:; - - /* "msgpack/_msgpack.pyx":75 - * else: - * self._bencoding = encoding - * self.encoding = PyBytes_AsString(self._bencoding) # <<<<<<<<<<<<<< - * if isinstance(unicode_errors, unicode): - * self._berrors = unicode_errors.encode('ascii') - */ - __pyx_t_3 = ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_bencoding; - __Pyx_INCREF(__pyx_t_3); - __pyx_t_4 = PyBytes_AsString(__pyx_t_3); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->encoding = __pyx_t_4; - - /* "msgpack/_msgpack.pyx":76 - * self._bencoding = encoding - * self.encoding = PyBytes_AsString(self._bencoding) - * if isinstance(unicode_errors, unicode): # <<<<<<<<<<<<<< - * self._berrors = unicode_errors.encode('ascii') - * else: - */ - __pyx_t_3 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_3); - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_unicode_errors, __pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":77 - * self.encoding = PyBytes_AsString(self._bencoding) - * if isinstance(unicode_errors, unicode): - * self._berrors = unicode_errors.encode('ascii') # <<<<<<<<<<<<<< - * else: - * self._berrors = unicode_errors - */ - __pyx_t_3 = PyObject_GetAttr(__pyx_v_unicode_errors, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_berrors); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_berrors); - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_berrors = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L10; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":79 - * self._berrors = unicode_errors.encode('ascii') - * else: - * self._berrors = unicode_errors # <<<<<<<<<<<<<< - * self.unicode_errors = PyBytes_AsString(self._berrors) - * - */ - __Pyx_INCREF(__pyx_v_unicode_errors); - __Pyx_GIVEREF(__pyx_v_unicode_errors); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_berrors); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_berrors); - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_berrors = __pyx_v_unicode_errors; - } - __pyx_L10:; - - /* "msgpack/_msgpack.pyx":80 - * else: - * self._berrors = unicode_errors - * self.unicode_errors = PyBytes_AsString(self._berrors) # <<<<<<<<<<<<<< - * - * def __dealloc__(self): - */ - __pyx_t_2 = ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->_berrors; - __Pyx_INCREF(__pyx_t_2); - __pyx_t_4 = PyBytes_AsString(__pyx_t_2); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->unicode_errors = __pyx_t_4; - } - __pyx_L8:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("msgpack._msgpack.Packer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":82 - * self.unicode_errors = PyBytes_AsString(self._berrors) - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * free(self.pk.buf); - * - */ - -static void __pyx_pf_7msgpack_8_msgpack_6Packer_2__dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_pf_7msgpack_8_msgpack_6Packer_2__dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__"); - - /* "msgpack/_msgpack.pyx":83 - * - * def __dealloc__(self): - * free(self.pk.buf); # <<<<<<<<<<<<<< - * - * cdef int _pack(self, object o, int nest_limit=DEFAULT_RECURSE_LIMIT) except -1: - */ - free(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->pk.buf); - - __Pyx_RefNannyFinishContext(); -} - -/* "msgpack/_msgpack.pyx":85 - * free(self.pk.buf); - * - * cdef int _pack(self, object o, int nest_limit=DEFAULT_RECURSE_LIMIT) except -1: # <<<<<<<<<<<<<< - * cdef long long llval - * cdef unsigned long long ullval - */ - -static int __pyx_f_7msgpack_8_msgpack_6Packer__pack(struct __pyx_obj_7msgpack_8_msgpack_Packer *__pyx_v_self, PyObject *__pyx_v_o, struct __pyx_opt_args_7msgpack_8_msgpack_6Packer__pack *__pyx_optional_args) { - int __pyx_v_nest_limit = __pyx_k_8; - PY_LONG_LONG __pyx_v_llval; - unsigned PY_LONG_LONG __pyx_v_ullval; - long __pyx_v_longval; - double __pyx_v_fval; - char *__pyx_v_rawval; - int __pyx_v_ret; - PyObject *__pyx_v_d = 0; - PyObject *__pyx_v_k = NULL; - PyObject *__pyx_v_v = NULL; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - unsigned PY_LONG_LONG __pyx_t_3; - PY_LONG_LONG __pyx_t_4; - long __pyx_t_5; - double __pyx_t_6; - char *__pyx_t_7; - Py_ssize_t __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - PyObject *(*__pyx_t_10)(PyObject *); - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *(*__pyx_t_14)(PyObject *); - int __pyx_t_15; - struct __pyx_opt_args_7msgpack_8_msgpack_6Packer__pack __pyx_t_16; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_pack"); - if (__pyx_optional_args) { - if (__pyx_optional_args->__pyx_n > 0) { - __pyx_v_nest_limit = __pyx_optional_args->nest_limit; - } - } - __Pyx_INCREF(__pyx_v_o); - - /* "msgpack/_msgpack.pyx":94 - * cdef dict d - * - * if nest_limit < 0: # <<<<<<<<<<<<<< - * raise ValueError("Too deep.") - * - */ - __pyx_t_1 = (__pyx_v_nest_limit < 0); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":95 - * - * if nest_limit < 0: - * raise ValueError("Too deep.") # <<<<<<<<<<<<<< - * - * if o is None: - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; - } - __pyx_L3:; - - /* "msgpack/_msgpack.pyx":97 - * raise ValueError("Too deep.") - * - * if o is None: # <<<<<<<<<<<<<< - * ret = msgpack_pack_nil(&self.pk) - * elif isinstance(o, bool): - */ - __pyx_t_1 = (__pyx_v_o == Py_None); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":98 - * - * if o is None: - * ret = msgpack_pack_nil(&self.pk) # <<<<<<<<<<<<<< - * elif isinstance(o, bool): - * if o: - */ - __pyx_v_ret = msgpack_pack_nil((&__pyx_v_self->pk)); - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":99 - * if o is None: - * ret = msgpack_pack_nil(&self.pk) - * elif isinstance(o, bool): # <<<<<<<<<<<<<< - * if o: - * ret = msgpack_pack_true(&self.pk) - */ - __pyx_t_2 = ((PyObject *)((PyObject*)__pyx_ptype_7cpython_4bool_bool)); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":100 - * ret = msgpack_pack_nil(&self.pk) - * elif isinstance(o, bool): - * if o: # <<<<<<<<<<<<<< - * ret = msgpack_pack_true(&self.pk) - * else: - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_o); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":101 - * elif isinstance(o, bool): - * if o: - * ret = msgpack_pack_true(&self.pk) # <<<<<<<<<<<<<< - * else: - * ret = msgpack_pack_false(&self.pk) - */ - __pyx_v_ret = msgpack_pack_true((&__pyx_v_self->pk)); - goto __pyx_L5; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":103 - * ret = msgpack_pack_true(&self.pk) - * else: - * ret = msgpack_pack_false(&self.pk) # <<<<<<<<<<<<<< - * elif PyLong_Check(o): - * if o > 0: - */ - __pyx_v_ret = msgpack_pack_false((&__pyx_v_self->pk)); - } - __pyx_L5:; - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":104 - * else: - * ret = msgpack_pack_false(&self.pk) - * elif PyLong_Check(o): # <<<<<<<<<<<<<< - * if o > 0: - * ullval = o - */ - __pyx_t_1 = PyLong_Check(__pyx_v_o); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":105 - * ret = msgpack_pack_false(&self.pk) - * elif PyLong_Check(o): - * if o > 0: # <<<<<<<<<<<<<< - * ullval = o - * ret = msgpack_pack_unsigned_long_long(&self.pk, ullval) - */ - __pyx_t_2 = PyObject_RichCompare(__pyx_v_o, __pyx_int_0, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":106 - * elif PyLong_Check(o): - * if o > 0: - * ullval = o # <<<<<<<<<<<<<< - * ret = msgpack_pack_unsigned_long_long(&self.pk, ullval) - * else: - */ - __pyx_t_3 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_v_o); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ullval = __pyx_t_3; - - /* "msgpack/_msgpack.pyx":107 - * if o > 0: - * ullval = o - * ret = msgpack_pack_unsigned_long_long(&self.pk, ullval) # <<<<<<<<<<<<<< - * else: - * llval = o - */ - __pyx_v_ret = msgpack_pack_unsigned_long_long((&__pyx_v_self->pk), __pyx_v_ullval); - goto __pyx_L6; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":109 - * ret = msgpack_pack_unsigned_long_long(&self.pk, ullval) - * else: - * llval = o # <<<<<<<<<<<<<< - * ret = msgpack_pack_long_long(&self.pk, llval) - * elif PyInt_Check(o): - */ - __pyx_t_4 = __Pyx_PyInt_AsLongLong(__pyx_v_o); if (unlikely((__pyx_t_4 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_llval = __pyx_t_4; - - /* "msgpack/_msgpack.pyx":110 - * else: - * llval = o - * ret = msgpack_pack_long_long(&self.pk, llval) # <<<<<<<<<<<<<< - * elif PyInt_Check(o): - * longval = o - */ - __pyx_v_ret = msgpack_pack_long_long((&__pyx_v_self->pk), __pyx_v_llval); - } - __pyx_L6:; - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":111 - * llval = o - * ret = msgpack_pack_long_long(&self.pk, llval) - * elif PyInt_Check(o): # <<<<<<<<<<<<<< - * longval = o - * ret = msgpack_pack_long(&self.pk, longval) - */ - __pyx_t_1 = PyInt_Check(__pyx_v_o); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":112 - * ret = msgpack_pack_long_long(&self.pk, llval) - * elif PyInt_Check(o): - * longval = o # <<<<<<<<<<<<<< - * ret = msgpack_pack_long(&self.pk, longval) - * elif PyFloat_Check(o): - */ - __pyx_t_5 = __Pyx_PyInt_AsLong(__pyx_v_o); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_longval = __pyx_t_5; - - /* "msgpack/_msgpack.pyx":113 - * elif PyInt_Check(o): - * longval = o - * ret = msgpack_pack_long(&self.pk, longval) # <<<<<<<<<<<<<< - * elif PyFloat_Check(o): - * fval = o - */ - __pyx_v_ret = msgpack_pack_long((&__pyx_v_self->pk), __pyx_v_longval); - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":114 - * longval = o - * ret = msgpack_pack_long(&self.pk, longval) - * elif PyFloat_Check(o): # <<<<<<<<<<<<<< - * fval = o - * ret = msgpack_pack_double(&self.pk, fval) - */ - __pyx_t_1 = PyFloat_Check(__pyx_v_o); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":115 - * ret = msgpack_pack_long(&self.pk, longval) - * elif PyFloat_Check(o): - * fval = o # <<<<<<<<<<<<<< - * ret = msgpack_pack_double(&self.pk, fval) - * elif PyBytes_Check(o): - */ - __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_v_o); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_fval = __pyx_t_6; - - /* "msgpack/_msgpack.pyx":116 - * elif PyFloat_Check(o): - * fval = o - * ret = msgpack_pack_double(&self.pk, fval) # <<<<<<<<<<<<<< - * elif PyBytes_Check(o): - * rawval = o - */ - __pyx_v_ret = msgpack_pack_double((&__pyx_v_self->pk), __pyx_v_fval); - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":117 - * fval = o - * ret = msgpack_pack_double(&self.pk, fval) - * elif PyBytes_Check(o): # <<<<<<<<<<<<<< - * rawval = o - * ret = msgpack_pack_raw(&self.pk, len(o)) - */ - __pyx_t_1 = PyBytes_Check(__pyx_v_o); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":118 - * ret = msgpack_pack_double(&self.pk, fval) - * elif PyBytes_Check(o): - * rawval = o # <<<<<<<<<<<<<< - * ret = msgpack_pack_raw(&self.pk, len(o)) - * if ret == 0: - */ - __pyx_t_7 = PyBytes_AsString(__pyx_v_o); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_rawval = __pyx_t_7; - - /* "msgpack/_msgpack.pyx":119 - * elif PyBytes_Check(o): - * rawval = o - * ret = msgpack_pack_raw(&self.pk, len(o)) # <<<<<<<<<<<<<< - * if ret == 0: - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - */ - __pyx_t_8 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = msgpack_pack_raw((&__pyx_v_self->pk), __pyx_t_8); - - /* "msgpack/_msgpack.pyx":120 - * rawval = o - * ret = msgpack_pack_raw(&self.pk, len(o)) - * if ret == 0: # <<<<<<<<<<<<<< - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - * elif PyUnicode_Check(o): - */ - __pyx_t_1 = (__pyx_v_ret == 0); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":121 - * ret = msgpack_pack_raw(&self.pk, len(o)) - * if ret == 0: - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) # <<<<<<<<<<<<<< - * elif PyUnicode_Check(o): - * if not self.encoding: - */ - __pyx_t_8 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = msgpack_pack_raw_body((&__pyx_v_self->pk), __pyx_v_rawval, __pyx_t_8); - goto __pyx_L7; - } - __pyx_L7:; - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":122 - * if ret == 0: - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - * elif PyUnicode_Check(o): # <<<<<<<<<<<<<< - * if not self.encoding: - * raise TypeError("Can't encode utf-8 no encoding is specified") - */ - __pyx_t_1 = PyUnicode_Check(__pyx_v_o); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":123 - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - * elif PyUnicode_Check(o): - * if not self.encoding: # <<<<<<<<<<<<<< - * raise TypeError("Can't encode utf-8 no encoding is specified") - * o = PyUnicode_AsEncodedString(o, self.encoding, self.unicode_errors) - */ - __pyx_t_1 = (!(__pyx_v_self->encoding != 0)); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":124 - * elif PyUnicode_Check(o): - * if not self.encoding: - * raise TypeError("Can't encode utf-8 no encoding is specified") # <<<<<<<<<<<<<< - * o = PyUnicode_AsEncodedString(o, self.encoding, self.unicode_errors) - * rawval = o - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L8; - } - __pyx_L8:; - - /* "msgpack/_msgpack.pyx":125 - * if not self.encoding: - * raise TypeError("Can't encode utf-8 no encoding is specified") - * o = PyUnicode_AsEncodedString(o, self.encoding, self.unicode_errors) # <<<<<<<<<<<<<< - * rawval = o - * ret = msgpack_pack_raw(&self.pk, len(o)) - */ - __pyx_t_2 = PyUnicode_AsEncodedString(__pyx_v_o, __pyx_v_self->encoding, __pyx_v_self->unicode_errors); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_v_o); - __pyx_v_o = __pyx_t_2; - __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":126 - * raise TypeError("Can't encode utf-8 no encoding is specified") - * o = PyUnicode_AsEncodedString(o, self.encoding, self.unicode_errors) - * rawval = o # <<<<<<<<<<<<<< - * ret = msgpack_pack_raw(&self.pk, len(o)) - * if ret == 0: - */ - __pyx_t_7 = PyBytes_AsString(__pyx_v_o); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_rawval = __pyx_t_7; - - /* "msgpack/_msgpack.pyx":127 - * o = PyUnicode_AsEncodedString(o, self.encoding, self.unicode_errors) - * rawval = o - * ret = msgpack_pack_raw(&self.pk, len(o)) # <<<<<<<<<<<<<< - * if ret == 0: - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - */ - __pyx_t_8 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = msgpack_pack_raw((&__pyx_v_self->pk), __pyx_t_8); - - /* "msgpack/_msgpack.pyx":128 - * rawval = o - * ret = msgpack_pack_raw(&self.pk, len(o)) - * if ret == 0: # <<<<<<<<<<<<<< - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - * elif PyDict_Check(o): - */ - __pyx_t_1 = (__pyx_v_ret == 0); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":129 - * ret = msgpack_pack_raw(&self.pk, len(o)) - * if ret == 0: - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) # <<<<<<<<<<<<<< - * elif PyDict_Check(o): - * d = o - */ - __pyx_t_8 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = msgpack_pack_raw_body((&__pyx_v_self->pk), __pyx_v_rawval, __pyx_t_8); - goto __pyx_L9; - } - __pyx_L9:; - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":130 - * if ret == 0: - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - * elif PyDict_Check(o): # <<<<<<<<<<<<<< - * d = o - * ret = msgpack_pack_map(&self.pk, len(d)) - */ - __pyx_t_1 = PyDict_Check(__pyx_v_o); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":131 - * ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - * elif PyDict_Check(o): - * d = o # <<<<<<<<<<<<<< - * ret = msgpack_pack_map(&self.pk, len(d)) - * if ret == 0: - */ - if (!(likely(PyDict_CheckExact(__pyx_v_o))||((__pyx_v_o) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected dict, got %.200s", Py_TYPE(__pyx_v_o)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_INCREF(__pyx_v_o); - __pyx_v_d = ((PyObject*)__pyx_v_o); - - /* "msgpack/_msgpack.pyx":132 - * elif PyDict_Check(o): - * d = o - * ret = msgpack_pack_map(&self.pk, len(d)) # <<<<<<<<<<<<<< - * if ret == 0: - * for k,v in d.items(): - */ - if (unlikely(((PyObject *)__pyx_v_d) == Py_None)) { - PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_8 = PyDict_Size(((PyObject *)__pyx_v_d)); - __pyx_v_ret = msgpack_pack_map((&__pyx_v_self->pk), __pyx_t_8); - - /* "msgpack/_msgpack.pyx":133 - * d = o - * ret = msgpack_pack_map(&self.pk, len(d)) - * if ret == 0: # <<<<<<<<<<<<<< - * for k,v in d.items(): - * ret = self._pack(k, nest_limit-1) - */ - __pyx_t_1 = (__pyx_v_ret == 0); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":134 - * ret = msgpack_pack_map(&self.pk, len(d)) - * if ret == 0: - * for k,v in d.items(): # <<<<<<<<<<<<<< - * ret = self._pack(k, nest_limit-1) - * if ret != 0: break - */ - if (unlikely(((PyObject *)__pyx_v_d) == Py_None)) { - PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "items"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_2 = PyDict_Items(__pyx_v_d); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { - __pyx_t_9 = __pyx_t_2; __Pyx_INCREF(__pyx_t_9); __pyx_t_8 = 0; - __pyx_t_10 = NULL; - } else { - __pyx_t_8 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - for (;;) { - if (PyList_CheckExact(__pyx_t_9)) { - if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_9)) break; - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; - } else if (PyTuple_CheckExact(__pyx_t_9)) { - if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_9)) break; - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; - } else { - __pyx_t_2 = __pyx_t_10(__pyx_t_9); - if (unlikely(!__pyx_t_2)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_2); - } - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - if (likely(PyTuple_CheckExact(sequence))) { - if (unlikely(PyTuple_GET_SIZE(sequence) != 2)) { - if (PyTuple_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2); - else __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(sequence)); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); - } else { - if (unlikely(PyList_GET_SIZE(sequence) != 2)) { - if (PyList_GET_SIZE(sequence) > 2) __Pyx_RaiseTooManyValuesError(2); - else __Pyx_RaiseNeedMoreValuesError(PyList_GET_SIZE(sequence)); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_11 = PyList_GET_ITEM(sequence, 0); - __pyx_t_12 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_11); - __Pyx_INCREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_13 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_13); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext; - index = 0; __pyx_t_11 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L13_unpacking_failed; - __Pyx_GOTREF(__pyx_t_11); - index = 1; __pyx_t_12 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_12)) goto __pyx_L13_unpacking_failed; - __Pyx_GOTREF(__pyx_t_12); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - goto __pyx_L14_unpacking_done; - __pyx_L13_unpacking_failed:; - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration)) PyErr_Clear(); - if (!PyErr_Occurred()) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L14_unpacking_done:; - } - __Pyx_XDECREF(__pyx_v_k); - __pyx_v_k = __pyx_t_11; - __pyx_t_11 = 0; - __Pyx_XDECREF(__pyx_v_v); - __pyx_v_v = __pyx_t_12; - __pyx_t_12 = 0; - - /* "msgpack/_msgpack.pyx":135 - * if ret == 0: - * for k,v in d.items(): - * ret = self._pack(k, nest_limit-1) # <<<<<<<<<<<<<< - * if ret != 0: break - * ret = self._pack(v, nest_limit-1) - */ - __pyx_t_16.__pyx_n = 1; - __pyx_t_16.nest_limit = (__pyx_v_nest_limit - 1); - __pyx_t_15 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_k, &__pyx_t_16); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = __pyx_t_15; - - /* "msgpack/_msgpack.pyx":136 - * for k,v in d.items(): - * ret = self._pack(k, nest_limit-1) - * if ret != 0: break # <<<<<<<<<<<<<< - * ret = self._pack(v, nest_limit-1) - * if ret != 0: break - */ - __pyx_t_1 = (__pyx_v_ret != 0); - if (__pyx_t_1) { - goto __pyx_L12_break; - goto __pyx_L15; - } - __pyx_L15:; - - /* "msgpack/_msgpack.pyx":137 - * ret = self._pack(k, nest_limit-1) - * if ret != 0: break - * ret = self._pack(v, nest_limit-1) # <<<<<<<<<<<<<< - * if ret != 0: break - * elif PySequence_Check(o): - */ - __pyx_t_16.__pyx_n = 1; - __pyx_t_16.nest_limit = (__pyx_v_nest_limit - 1); - __pyx_t_15 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_v, &__pyx_t_16); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = __pyx_t_15; - - /* "msgpack/_msgpack.pyx":138 - * if ret != 0: break - * ret = self._pack(v, nest_limit-1) - * if ret != 0: break # <<<<<<<<<<<<<< - * elif PySequence_Check(o): - * ret = msgpack_pack_array(&self.pk, len(o)) - */ - __pyx_t_1 = (__pyx_v_ret != 0); - if (__pyx_t_1) { - goto __pyx_L12_break; - goto __pyx_L16; - } - __pyx_L16:; - } - __pyx_L12_break:; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L10; - } - __pyx_L10:; - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":139 - * ret = self._pack(v, nest_limit-1) - * if ret != 0: break - * elif PySequence_Check(o): # <<<<<<<<<<<<<< - * ret = msgpack_pack_array(&self.pk, len(o)) - * if ret == 0: - */ - __pyx_t_1 = PySequence_Check(__pyx_v_o); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":140 - * if ret != 0: break - * elif PySequence_Check(o): - * ret = msgpack_pack_array(&self.pk, len(o)) # <<<<<<<<<<<<<< - * if ret == 0: - * for v in o: - */ - __pyx_t_8 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = msgpack_pack_array((&__pyx_v_self->pk), __pyx_t_8); - - /* "msgpack/_msgpack.pyx":141 - * elif PySequence_Check(o): - * ret = msgpack_pack_array(&self.pk, len(o)) - * if ret == 0: # <<<<<<<<<<<<<< - * for v in o: - * ret = self._pack(v, nest_limit-1) - */ - __pyx_t_1 = (__pyx_v_ret == 0); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":142 - * ret = msgpack_pack_array(&self.pk, len(o)) - * if ret == 0: - * for v in o: # <<<<<<<<<<<<<< - * ret = self._pack(v, nest_limit-1) - * if ret != 0: break - */ - if (PyList_CheckExact(__pyx_v_o) || PyTuple_CheckExact(__pyx_v_o)) { - __pyx_t_9 = __pyx_v_o; __Pyx_INCREF(__pyx_t_9); __pyx_t_8 = 0; - __pyx_t_10 = NULL; - } else { - __pyx_t_8 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; - } - for (;;) { - if (PyList_CheckExact(__pyx_t_9)) { - if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_9)) break; - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; - } else if (PyTuple_CheckExact(__pyx_t_9)) { - if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_9)) break; - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; - } else { - __pyx_t_2 = __pyx_t_10(__pyx_t_9); - if (unlikely(!__pyx_t_2)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_2); - } - __Pyx_XDECREF(__pyx_v_v); - __pyx_v_v = __pyx_t_2; - __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":143 - * if ret == 0: - * for v in o: - * ret = self._pack(v, nest_limit-1) # <<<<<<<<<<<<<< - * if ret != 0: break - * elif self._default: - */ - __pyx_t_16.__pyx_n = 1; - __pyx_t_16.nest_limit = (__pyx_v_nest_limit - 1); - __pyx_t_15 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_v, &__pyx_t_16); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = __pyx_t_15; - - /* "msgpack/_msgpack.pyx":144 - * for v in o: - * ret = self._pack(v, nest_limit-1) - * if ret != 0: break # <<<<<<<<<<<<<< - * elif self._default: - * o = self._default(o) - */ - __pyx_t_1 = (__pyx_v_ret != 0); - if (__pyx_t_1) { - goto __pyx_L19_break; - goto __pyx_L20; - } - __pyx_L20:; - } - __pyx_L19_break:; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L17; - } - __pyx_L17:; - goto __pyx_L4; - } - - /* "msgpack/_msgpack.pyx":145 - * ret = self._pack(v, nest_limit-1) - * if ret != 0: break - * elif self._default: # <<<<<<<<<<<<<< - * o = self._default(o) - * ret = self._pack(o, nest_limit-1) - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_default); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":146 - * if ret != 0: break - * elif self._default: - * o = self._default(o) # <<<<<<<<<<<<<< - * ret = self._pack(o, nest_limit-1) - * else: - */ - __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_INCREF(__pyx_v_o); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_o); - __Pyx_GIVEREF(__pyx_v_o); - __pyx_t_2 = PyObject_Call(__pyx_v_self->_default, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __Pyx_DECREF(__pyx_v_o); - __pyx_v_o = __pyx_t_2; - __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":147 - * elif self._default: - * o = self._default(o) - * ret = self._pack(o, nest_limit-1) # <<<<<<<<<<<<<< - * else: - * raise TypeError("can't serialize %r" % (o,)) - */ - __pyx_t_16.__pyx_n = 1; - __pyx_t_16.nest_limit = (__pyx_v_nest_limit - 1); - __pyx_t_15 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_o, &__pyx_t_16); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = __pyx_t_15; - goto __pyx_L4; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":149 - * ret = self._pack(o, nest_limit-1) - * else: - * raise TypeError("can't serialize %r" % (o,)) # <<<<<<<<<<<<<< - * return ret - * - */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __Pyx_INCREF(__pyx_v_o); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_o); - __Pyx_GIVEREF(__pyx_v_o); - __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_9)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); - __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_Raise(__pyx_t_9, 0, 0, 0); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_L4:; - - /* "msgpack/_msgpack.pyx":150 - * else: - * raise TypeError("can't serialize %r" % (o,)) - * return ret # <<<<<<<<<<<<<< - * - * def pack(self, object obj): - */ - __pyx_r = __pyx_v_ret; - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - __Pyx_AddTraceback("msgpack._msgpack.Packer._pack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_d); - __Pyx_XDECREF(__pyx_v_k); - __Pyx_XDECREF(__pyx_v_v); - __Pyx_XDECREF(__pyx_v_o); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":152 - * return ret - * - * def pack(self, object obj): # <<<<<<<<<<<<<< - * cdef int ret - * ret = self._pack(obj, DEFAULT_RECURSE_LIMIT) - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_6Packer_3pack(PyObject *__pyx_v_self, PyObject *__pyx_v_obj); /*proto*/ -static char __pyx_doc_7msgpack_8_msgpack_6Packer_3pack[] = "Packer.pack(self, obj)"; -static PyObject *__pyx_pf_7msgpack_8_msgpack_6Packer_3pack(PyObject *__pyx_v_self, PyObject *__pyx_v_obj) { - int __pyx_v_ret; - PyObject *__pyx_v_buf = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - struct __pyx_opt_args_7msgpack_8_msgpack_6Packer__pack __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("pack"); - - /* "msgpack/_msgpack.pyx":154 - * def pack(self, object obj): - * cdef int ret - * ret = self._pack(obj, DEFAULT_RECURSE_LIMIT) # <<<<<<<<<<<<<< - * if ret: - * raise TypeError - */ - __pyx_t_2.__pyx_n = 1; - __pyx_t_2.nest_limit = __pyx_v_7msgpack_8_msgpack_DEFAULT_RECURSE_LIMIT; - __pyx_t_1 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer *)((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->__pyx_vtab)->_pack(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self), __pyx_v_obj, &__pyx_t_2); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = __pyx_t_1; - - /* "msgpack/_msgpack.pyx":155 - * cdef int ret - * ret = self._pack(obj, DEFAULT_RECURSE_LIMIT) - * if ret: # <<<<<<<<<<<<<< - * raise TypeError - * buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length) - */ - if (__pyx_v_ret) { - - /* "msgpack/_msgpack.pyx":156 - * ret = self._pack(obj, DEFAULT_RECURSE_LIMIT) - * if ret: - * raise TypeError # <<<<<<<<<<<<<< - * buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length) - * self.pk.length = 0 - */ - __Pyx_Raise(__pyx_builtin_TypeError, 0, 0, 0); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L5; - } - __pyx_L5:; - - /* "msgpack/_msgpack.pyx":157 - * if ret: - * raise TypeError - * buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length) # <<<<<<<<<<<<<< - * self.pk.length = 0 - * return buf - */ - __pyx_t_3 = ((PyObject *)PyBytes_FromStringAndSize(((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->pk.buf, ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->pk.length)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_v_buf = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - - /* "msgpack/_msgpack.pyx":158 - * raise TypeError - * buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length) - * self.pk.length = 0 # <<<<<<<<<<<<<< - * return buf - * - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)__pyx_v_self)->pk.length = 0; - - /* "msgpack/_msgpack.pyx":159 - * buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length) - * self.pk.length = 0 - * return buf # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_buf)); - __pyx_r = ((PyObject *)__pyx_v_buf); - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("msgpack._msgpack.Packer.pack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_buf); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":162 - * - * - * def pack(object o, object stream, default=None, encoding='utf-8', unicode_errors='strict'): # <<<<<<<<<<<<<< - * """ - * pack an object `o` and write it to stream).""" - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_pack(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7msgpack_8_msgpack_pack[] = "pack(o, stream, default=None, encoding='utf-8', unicode_errors='strict')\n\n pack an object `o` and write it to stream)."; -static PyMethodDef __pyx_mdef_7msgpack_8_msgpack_pack = {__Pyx_NAMESTR("pack"), (PyCFunction)__pyx_pf_7msgpack_8_msgpack_pack, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7msgpack_8_msgpack_pack)}; -static PyObject *__pyx_pf_7msgpack_8_msgpack_pack(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_o = 0; - PyObject *__pyx_v_stream = 0; - PyObject *__pyx_v_default = 0; - PyObject *__pyx_v_encoding = 0; - PyObject *__pyx_v_unicode_errors = 0; - PyObject *__pyx_v_packer = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__o,&__pyx_n_s__stream,&__pyx_n_s__default,&__pyx_n_s__encoding,&__pyx_n_s__unicode_errors,0}; - __Pyx_RefNannySetupContext("pack"); - __pyx_self = __pyx_self; - { - PyObject* values[5] = {0,0,0,0,0}; - values[2] = ((PyObject *)Py_None); - values[3] = ((PyObject *)__pyx_kp_s_3); - values[4] = ((PyObject *)__pyx_n_s__strict); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__o); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream); - if (likely(values[1])) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("pack", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__default); - if (value) { values[2] = value; kw_args--; } - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding); - if (value) { values[3] = value; kw_args--; } - } - case 4: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unicode_errors); - if (value) { values[4] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "pack") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_o = values[0]; - __pyx_v_stream = values[1]; - __pyx_v_default = values[2]; - __pyx_v_encoding = values[3]; - __pyx_v_unicode_errors = values[4]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("pack", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("msgpack._msgpack.pack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - - /* "msgpack/_msgpack.pyx":165 - * """ - * pack an object `o` and write it to stream).""" - * packer = Packer(default=default, encoding=encoding, unicode_errors=unicode_errors) # <<<<<<<<<<<<<< - * stream.write(packer.pack(o)) - * - */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__default), __pyx_v_default) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__encoding), __pyx_v_encoding) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__unicode_errors), __pyx_v_unicode_errors) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_7msgpack_8_msgpack_Packer)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_v_packer = __pyx_t_2; - __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":166 - * pack an object `o` and write it to stream).""" - * packer = Packer(default=default, encoding=encoding, unicode_errors=unicode_errors) - * stream.write(packer.pack(o)) # <<<<<<<<<<<<<< - * - * def packb(object o, default=None, encoding='utf-8', unicode_errors='strict'): - */ - __pyx_t_2 = PyObject_GetAttr(__pyx_v_stream, __pyx_n_s__write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_v_packer, __pyx_n_s__pack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __Pyx_INCREF(__pyx_v_o); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o); - __Pyx_GIVEREF(__pyx_v_o); - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("msgpack._msgpack.pack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_packer); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":168 - * stream.write(packer.pack(o)) - * - * def packb(object o, default=None, encoding='utf-8', unicode_errors='strict'): # <<<<<<<<<<<<<< - * """ - * pack o and return packed bytes.""" - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_1packb(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7msgpack_8_msgpack_1packb[] = "packb(o, default=None, encoding='utf-8', unicode_errors='strict')\n\n pack o and return packed bytes."; -static PyMethodDef __pyx_mdef_7msgpack_8_msgpack_1packb = {__Pyx_NAMESTR("packb"), (PyCFunction)__pyx_pf_7msgpack_8_msgpack_1packb, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7msgpack_8_msgpack_1packb)}; -static PyObject *__pyx_pf_7msgpack_8_msgpack_1packb(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_o = 0; - PyObject *__pyx_v_default = 0; - PyObject *__pyx_v_encoding = 0; - PyObject *__pyx_v_unicode_errors = 0; - PyObject *__pyx_v_packer = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__o,&__pyx_n_s__default,&__pyx_n_s__encoding,&__pyx_n_s__unicode_errors,0}; - __Pyx_RefNannySetupContext("packb"); - __pyx_self = __pyx_self; - { - PyObject* values[4] = {0,0,0,0}; - values[1] = ((PyObject *)Py_None); - values[2] = ((PyObject *)__pyx_kp_s_3); - values[3] = ((PyObject *)__pyx_n_s__strict); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__o); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__default); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding); - if (value) { values[2] = value; kw_args--; } - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unicode_errors); - if (value) { values[3] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "packb") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_o = values[0]; - __pyx_v_default = values[1]; - __pyx_v_encoding = values[2]; - __pyx_v_unicode_errors = values[3]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("packb", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("msgpack._msgpack.packb", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - - /* "msgpack/_msgpack.pyx":171 - * """ - * pack o and return packed bytes.""" - * packer = Packer(default=default, encoding=encoding, unicode_errors=unicode_errors) # <<<<<<<<<<<<<< - * return packer.pack(o) - * - */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__default), __pyx_v_default) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__encoding), __pyx_v_encoding) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__unicode_errors), __pyx_v_unicode_errors) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_7msgpack_8_msgpack_Packer)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_v_packer = __pyx_t_2; - __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":172 - * pack o and return packed bytes.""" - * packer = Packer(default=default, encoding=encoding, unicode_errors=unicode_errors) - * return packer.pack(o) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_GetAttr(__pyx_v_packer, __pyx_n_s__pack); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_INCREF(__pyx_v_o); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_o); - __Pyx_GIVEREF(__pyx_v_o); - __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("msgpack._msgpack.packb", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_packer); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":196 - * - * - * def unpackb(object packed, object object_hook=None, object list_hook=None, bint use_list=0, encoding=None, unicode_errors="strict"): # <<<<<<<<<<<<<< - * """ - * Unpack packed_bytes to object. Returns an unpacked object.""" - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_2unpackb(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7msgpack_8_msgpack_2unpackb[] = "unpackb(packed, object_hook=None, list_hook=None, int use_list=0, encoding=None, unicode_errors='strict')\n\n Unpack packed_bytes to object. Returns an unpacked object."; -static PyMethodDef __pyx_mdef_7msgpack_8_msgpack_2unpackb = {__Pyx_NAMESTR("unpackb"), (PyCFunction)__pyx_pf_7msgpack_8_msgpack_2unpackb, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7msgpack_8_msgpack_2unpackb)}; -static PyObject *__pyx_pf_7msgpack_8_msgpack_2unpackb(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_packed = 0; - PyObject *__pyx_v_object_hook = 0; - PyObject *__pyx_v_list_hook = 0; - int __pyx_v_use_list; - PyObject *__pyx_v_encoding = 0; - PyObject *__pyx_v_unicode_errors = 0; - template_context __pyx_v_ctx; - size_t __pyx_v_off; - int __pyx_v_ret; - char *__pyx_v_buf; - Py_ssize_t __pyx_v_buf_len; - void *__pyx_v_enc; - void *__pyx_v_err; - PyObject *__pyx_v_bencoding = NULL; - PyObject *__pyx_v_berrors = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - char *__pyx_t_5; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__packed,&__pyx_n_s__object_hook,&__pyx_n_s__list_hook,&__pyx_n_s__use_list,&__pyx_n_s__encoding,&__pyx_n_s__unicode_errors,0}; - __Pyx_RefNannySetupContext("unpackb"); - __pyx_self = __pyx_self; - { - PyObject* values[6] = {0,0,0,0,0,0}; - values[1] = ((PyObject *)Py_None); - values[2] = ((PyObject *)Py_None); - values[4] = ((PyObject *)Py_None); - values[5] = ((PyObject *)__pyx_n_s__strict); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__packed); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__object_hook); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__list_hook); - if (value) { values[2] = value; kw_args--; } - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_list); - if (value) { values[3] = value; kw_args--; } - } - case 4: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding); - if (value) { values[4] = value; kw_args--; } - } - case 5: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unicode_errors); - if (value) { values[5] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "unpackb") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_packed = values[0]; - __pyx_v_object_hook = values[1]; - __pyx_v_list_hook = values[2]; - if (values[3]) { - __pyx_v_use_list = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_use_list == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_use_list = ((int)0); - } - __pyx_v_encoding = values[4]; - __pyx_v_unicode_errors = values[5]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("unpackb", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("msgpack._msgpack.unpackb", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - - /* "msgpack/_msgpack.pyx":200 - * Unpack packed_bytes to object. Returns an unpacked object.""" - * cdef template_context ctx - * cdef size_t off = 0 # <<<<<<<<<<<<<< - * cdef int ret - * - */ - __pyx_v_off = 0; - - /* "msgpack/_msgpack.pyx":205 - * cdef char* buf - * cdef Py_ssize_t buf_len - * PyObject_AsReadBuffer(packed, &buf, &buf_len) # <<<<<<<<<<<<<< - * - * if encoding is None: - */ - __pyx_t_1 = PyObject_AsReadBuffer(__pyx_v_packed, ((const void* *)(&__pyx_v_buf)), (&__pyx_v_buf_len)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "msgpack/_msgpack.pyx":207 - * PyObject_AsReadBuffer(packed, &buf, &buf_len) - * - * if encoding is None: # <<<<<<<<<<<<<< - * enc = NULL - * err = NULL - */ - __pyx_t_2 = (__pyx_v_encoding == Py_None); - if (__pyx_t_2) { - - /* "msgpack/_msgpack.pyx":208 - * - * if encoding is None: - * enc = NULL # <<<<<<<<<<<<<< - * err = NULL - * else: - */ - __pyx_v_enc = NULL; - - /* "msgpack/_msgpack.pyx":209 - * if encoding is None: - * enc = NULL - * err = NULL # <<<<<<<<<<<<<< - * else: - * if isinstance(encoding, unicode): - */ - __pyx_v_err = NULL; - goto __pyx_L6; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":211 - * err = NULL - * else: - * if isinstance(encoding, unicode): # <<<<<<<<<<<<<< - * bencoding = encoding.encode('ascii') - * else: - */ - __pyx_t_3 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_3); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_encoding, __pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_2) { - - /* "msgpack/_msgpack.pyx":212 - * else: - * if isinstance(encoding, unicode): - * bencoding = encoding.encode('ascii') # <<<<<<<<<<<<<< - * else: - * bencoding = encoding - */ - __pyx_t_3 = PyObject_GetAttr(__pyx_v_encoding, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_bencoding = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L7; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":214 - * bencoding = encoding.encode('ascii') - * else: - * bencoding = encoding # <<<<<<<<<<<<<< - * if isinstance(unicode_errors, unicode): - * berrors = unicode_errors.encode('ascii') - */ - __Pyx_INCREF(__pyx_v_encoding); - __pyx_v_bencoding = __pyx_v_encoding; - } - __pyx_L7:; - - /* "msgpack/_msgpack.pyx":215 - * else: - * bencoding = encoding - * if isinstance(unicode_errors, unicode): # <<<<<<<<<<<<<< - * berrors = unicode_errors.encode('ascii') - * else: - */ - __pyx_t_4 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_4); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_unicode_errors, __pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_2) { - - /* "msgpack/_msgpack.pyx":216 - * bencoding = encoding - * if isinstance(unicode_errors, unicode): - * berrors = unicode_errors.encode('ascii') # <<<<<<<<<<<<<< - * else: - * berrors = unicode_errors - */ - __pyx_t_4 = PyObject_GetAttr(__pyx_v_unicode_errors, __pyx_n_s__encode); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_15), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_berrors = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L8; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":218 - * berrors = unicode_errors.encode('ascii') - * else: - * berrors = unicode_errors # <<<<<<<<<<<<<< - * enc = PyBytes_AsString(bencoding) - * err = PyBytes_AsString(berrors) - */ - __Pyx_INCREF(__pyx_v_unicode_errors); - __pyx_v_berrors = __pyx_v_unicode_errors; - } - __pyx_L8:; - - /* "msgpack/_msgpack.pyx":219 - * else: - * berrors = unicode_errors - * enc = PyBytes_AsString(bencoding) # <<<<<<<<<<<<<< - * err = PyBytes_AsString(berrors) - * - */ - __pyx_t_5 = PyBytes_AsString(__pyx_v_bencoding); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_enc = __pyx_t_5; - - /* "msgpack/_msgpack.pyx":220 - * berrors = unicode_errors - * enc = PyBytes_AsString(bencoding) - * err = PyBytes_AsString(berrors) # <<<<<<<<<<<<<< - * - * template_init(&ctx) - */ - __pyx_t_5 = PyBytes_AsString(__pyx_v_berrors); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_err = __pyx_t_5; - } - __pyx_L6:; - - /* "msgpack/_msgpack.pyx":222 - * err = PyBytes_AsString(berrors) - * - * template_init(&ctx) # <<<<<<<<<<<<<< - * ctx.user.use_list = use_list - * ctx.user.object_hook = ctx.user.list_hook = NULL - */ - template_init((&__pyx_v_ctx)); - - /* "msgpack/_msgpack.pyx":223 - * - * template_init(&ctx) - * ctx.user.use_list = use_list # <<<<<<<<<<<<<< - * ctx.user.object_hook = ctx.user.list_hook = NULL - * ctx.user.encoding = enc - */ - __pyx_v_ctx.user.use_list = __pyx_v_use_list; - - /* "msgpack/_msgpack.pyx":224 - * template_init(&ctx) - * ctx.user.use_list = use_list - * ctx.user.object_hook = ctx.user.list_hook = NULL # <<<<<<<<<<<<<< - * ctx.user.encoding = enc - * ctx.user.unicode_errors = err - */ - __pyx_v_ctx.user.object_hook = NULL; - __pyx_v_ctx.user.list_hook = NULL; - - /* "msgpack/_msgpack.pyx":225 - * ctx.user.use_list = use_list - * ctx.user.object_hook = ctx.user.list_hook = NULL - * ctx.user.encoding = enc # <<<<<<<<<<<<<< - * ctx.user.unicode_errors = err - * if object_hook is not None: - */ - __pyx_v_ctx.user.encoding = __pyx_v_enc; - - /* "msgpack/_msgpack.pyx":226 - * ctx.user.object_hook = ctx.user.list_hook = NULL - * ctx.user.encoding = enc - * ctx.user.unicode_errors = err # <<<<<<<<<<<<<< - * if object_hook is not None: - * if not PyCallable_Check(object_hook): - */ - __pyx_v_ctx.user.unicode_errors = __pyx_v_err; - - /* "msgpack/_msgpack.pyx":227 - * ctx.user.encoding = enc - * ctx.user.unicode_errors = err - * if object_hook is not None: # <<<<<<<<<<<<<< - * if not PyCallable_Check(object_hook): - * raise TypeError("object_hook must be a callable.") - */ - __pyx_t_2 = (__pyx_v_object_hook != Py_None); - if (__pyx_t_2) { - - /* "msgpack/_msgpack.pyx":228 - * ctx.user.unicode_errors = err - * if object_hook is not None: - * if not PyCallable_Check(object_hook): # <<<<<<<<<<<<<< - * raise TypeError("object_hook must be a callable.") - * ctx.user.object_hook = object_hook - */ - __pyx_t_2 = (!PyCallable_Check(__pyx_v_object_hook)); - if (__pyx_t_2) { - - /* "msgpack/_msgpack.pyx":229 - * if object_hook is not None: - * if not PyCallable_Check(object_hook): - * raise TypeError("object_hook must be a callable.") # <<<<<<<<<<<<<< - * ctx.user.object_hook = object_hook - * if list_hook is not None: - */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_17), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L10; - } - __pyx_L10:; - - /* "msgpack/_msgpack.pyx":230 - * if not PyCallable_Check(object_hook): - * raise TypeError("object_hook must be a callable.") - * ctx.user.object_hook = object_hook # <<<<<<<<<<<<<< - * if list_hook is not None: - * if not PyCallable_Check(list_hook): - */ - __pyx_v_ctx.user.object_hook = ((PyObject *)__pyx_v_object_hook); - goto __pyx_L9; - } - __pyx_L9:; - - /* "msgpack/_msgpack.pyx":231 - * raise TypeError("object_hook must be a callable.") - * ctx.user.object_hook = object_hook - * if list_hook is not None: # <<<<<<<<<<<<<< - * if not PyCallable_Check(list_hook): - * raise TypeError("list_hook must be a callable.") - */ - __pyx_t_2 = (__pyx_v_list_hook != Py_None); - if (__pyx_t_2) { - - /* "msgpack/_msgpack.pyx":232 - * ctx.user.object_hook = object_hook - * if list_hook is not None: - * if not PyCallable_Check(list_hook): # <<<<<<<<<<<<<< - * raise TypeError("list_hook must be a callable.") - * ctx.user.list_hook = list_hook - */ - __pyx_t_2 = (!PyCallable_Check(__pyx_v_list_hook)); - if (__pyx_t_2) { - - /* "msgpack/_msgpack.pyx":233 - * if list_hook is not None: - * if not PyCallable_Check(list_hook): - * raise TypeError("list_hook must be a callable.") # <<<<<<<<<<<<<< - * ctx.user.list_hook = list_hook - * _gc_disable() - */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L12; - } - __pyx_L12:; - - /* "msgpack/_msgpack.pyx":234 - * if not PyCallable_Check(list_hook): - * raise TypeError("list_hook must be a callable.") - * ctx.user.list_hook = list_hook # <<<<<<<<<<<<<< - * _gc_disable() - * try: - */ - __pyx_v_ctx.user.list_hook = ((PyObject *)__pyx_v_list_hook); - goto __pyx_L11; - } - __pyx_L11:; - - /* "msgpack/_msgpack.pyx":235 - * raise TypeError("list_hook must be a callable.") - * ctx.user.list_hook = list_hook - * _gc_disable() # <<<<<<<<<<<<<< - * try: - * ret = template_execute(&ctx, buf, buf_len, &off) - */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___gc_disable); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "msgpack/_msgpack.pyx":236 - * ctx.user.list_hook = list_hook - * _gc_disable() - * try: # <<<<<<<<<<<<<< - * ret = template_execute(&ctx, buf, buf_len, &off) - * finally: - */ - /*try:*/ { - - /* "msgpack/_msgpack.pyx":237 - * _gc_disable() - * try: - * ret = template_execute(&ctx, buf, buf_len, &off) # <<<<<<<<<<<<<< - * finally: - * _gc_enable() - */ - __pyx_t_1 = template_execute((&__pyx_v_ctx), __pyx_v_buf, __pyx_v_buf_len, (&__pyx_v_off)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L14;} - __pyx_v_ret = __pyx_t_1; - } - - /* "msgpack/_msgpack.pyx":239 - * ret = template_execute(&ctx, buf, buf_len, &off) - * finally: - * _gc_enable() # <<<<<<<<<<<<<< - * if ret == 1: - * return template_data(&ctx) - */ - /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0; - __pyx_why = 0; goto __pyx_L15; - __pyx_L14: { - __pyx_why = 4; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L15; - } - __pyx_L15:; - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___gc_enable); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L16_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L16_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L17; - __pyx_L16_error:; - if (__pyx_why == 4) { - Py_XDECREF(__pyx_exc_type); - Py_XDECREF(__pyx_exc_value); - Py_XDECREF(__pyx_exc_tb); - } - goto __pyx_L1_error; - __pyx_L17:; - switch (__pyx_why) { - case 4: { - __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1_error; - } - } - } - - /* "msgpack/_msgpack.pyx":240 - * finally: - * _gc_enable() - * if ret == 1: # <<<<<<<<<<<<<< - * return template_data(&ctx) - * else: - */ - __pyx_t_2 = (__pyx_v_ret == 1); - if (__pyx_t_2) { - - /* "msgpack/_msgpack.pyx":241 - * _gc_enable() - * if ret == 1: - * return template_data(&ctx) # <<<<<<<<<<<<<< - * else: - * return None - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = template_data((&__pyx_v_ctx)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - goto __pyx_L18; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":243 - * return template_data(&ctx) - * else: - * return None # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; - } - __pyx_L18:; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("msgpack._msgpack.unpackb", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_bencoding); - __Pyx_XDECREF(__pyx_v_berrors); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":246 - * - * - * def unpack(object stream, object object_hook=None, object list_hook=None, bint use_list=0, encoding=None, unicode_errors="strict"): # <<<<<<<<<<<<<< - * """ - * unpack an object from stream. - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_3unpack(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_7msgpack_8_msgpack_3unpack[] = "unpack(stream, object_hook=None, list_hook=None, int use_list=0, encoding=None, unicode_errors='strict')\n\n unpack an object from stream.\n "; -static PyMethodDef __pyx_mdef_7msgpack_8_msgpack_3unpack = {__Pyx_NAMESTR("unpack"), (PyCFunction)__pyx_pf_7msgpack_8_msgpack_3unpack, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_7msgpack_8_msgpack_3unpack)}; -static PyObject *__pyx_pf_7msgpack_8_msgpack_3unpack(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_stream = 0; - PyObject *__pyx_v_object_hook = 0; - PyObject *__pyx_v_list_hook = 0; - int __pyx_v_use_list; - PyObject *__pyx_v_encoding = 0; - PyObject *__pyx_v_unicode_errors = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__stream,&__pyx_n_s__object_hook,&__pyx_n_s__list_hook,&__pyx_n_s__use_list,&__pyx_n_s__encoding,&__pyx_n_s__unicode_errors,0}; - __Pyx_RefNannySetupContext("unpack"); - __pyx_self = __pyx_self; - { - PyObject* values[6] = {0,0,0,0,0,0}; - values[1] = ((PyObject *)Py_None); - values[2] = ((PyObject *)Py_None); - values[4] = ((PyObject *)Py_None); - values[5] = ((PyObject *)__pyx_n_s__strict); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stream); - if (likely(values[0])) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__object_hook); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__list_hook); - if (value) { values[2] = value; kw_args--; } - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_list); - if (value) { values[3] = value; kw_args--; } - } - case 4: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding); - if (value) { values[4] = value; kw_args--; } - } - case 5: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unicode_errors); - if (value) { values[5] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "unpack") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_stream = values[0]; - __pyx_v_object_hook = values[1]; - __pyx_v_list_hook = values[2]; - if (values[3]) { - __pyx_v_use_list = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_use_list == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_use_list = ((int)0); - } - __pyx_v_encoding = values[4]; - __pyx_v_unicode_errors = values[5]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("unpack", 0, 1, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("msgpack._msgpack.unpack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - - /* "msgpack/_msgpack.pyx":250 - * unpack an object from stream. - * """ - * return unpackb(stream.read(), use_list=use_list, # <<<<<<<<<<<<<< - * object_hook=object_hook, list_hook=list_hook, encoding=encoding, unicode_errors=unicode_errors) - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__unpackb); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_v_stream, __pyx_n_s__read); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_use_list); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__use_list), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "msgpack/_msgpack.pyx":251 - * """ - * return unpackb(stream.read(), use_list=use_list, - * object_hook=object_hook, list_hook=list_hook, encoding=encoding, unicode_errors=unicode_errors) # <<<<<<<<<<<<<< - * - * cdef class Unpacker(object): - */ - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__object_hook), __pyx_v_object_hook) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__list_hook), __pyx_v_list_hook) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__encoding), __pyx_v_encoding) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__unicode_errors), __pyx_v_unicode_errors) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("msgpack._msgpack.unpack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":297 - * cdef char *unicode_errors - * - * def __cinit__(self): # <<<<<<<<<<<<<< - * self.buf = NULL - * - */ - -static int __pyx_pf_7msgpack_8_msgpack_8Unpacker___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pf_7msgpack_8_msgpack_8Unpacker___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__"); - if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; - - /* "msgpack/_msgpack.pyx":298 - * - * def __cinit__(self): - * self.buf = NULL # <<<<<<<<<<<<<< - * - * def __dealloc__(self): - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->buf = NULL; - - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":300 - * self.buf = NULL - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * free(self.buf) - * self.buf = NULL - */ - -static void __pyx_pf_7msgpack_8_msgpack_8Unpacker_1__dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_pf_7msgpack_8_msgpack_8Unpacker_1__dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__"); - - /* "msgpack/_msgpack.pyx":301 - * - * def __dealloc__(self): - * free(self.buf) # <<<<<<<<<<<<<< - * self.buf = NULL - * - */ - free(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->buf); - - /* "msgpack/_msgpack.pyx":302 - * def __dealloc__(self): - * free(self.buf) - * self.buf = NULL # <<<<<<<<<<<<<< - * - * def __init__(self, file_like=None, Py_ssize_t read_size=1024*1024, bint use_list=0, - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->buf = NULL; - - __Pyx_RefNannyFinishContext(); -} - -/* "msgpack/_msgpack.pyx":304 - * self.buf = NULL - * - * def __init__(self, file_like=None, Py_ssize_t read_size=1024*1024, bint use_list=0, # <<<<<<<<<<<<<< - * object object_hook=None, object list_hook=None, - * encoding=None, unicode_errors='strict'): - */ - -static int __pyx_pf_7msgpack_8_msgpack_8Unpacker_2__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pf_7msgpack_8_msgpack_8Unpacker_2__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_file_like = 0; - Py_ssize_t __pyx_v_read_size; - int __pyx_v_use_list; - PyObject *__pyx_v_object_hook = 0; - PyObject *__pyx_v_list_hook = 0; - PyObject *__pyx_v_encoding = 0; - PyObject *__pyx_v_unicode_errors = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - char *__pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__file_like,&__pyx_n_s__read_size,&__pyx_n_s__use_list,&__pyx_n_s__object_hook,&__pyx_n_s__list_hook,&__pyx_n_s__encoding,&__pyx_n_s__unicode_errors,0}; - __Pyx_RefNannySetupContext("__init__"); - { - PyObject* values[7] = {0,0,0,0,0,0,0}; - values[0] = ((PyObject *)Py_None); - - /* "msgpack/_msgpack.pyx":305 - * - * def __init__(self, file_like=None, Py_ssize_t read_size=1024*1024, bint use_list=0, - * object object_hook=None, object list_hook=None, # <<<<<<<<<<<<<< - * encoding=None, unicode_errors='strict'): - * self.use_list = use_list - */ - values[3] = ((PyObject *)Py_None); - values[4] = ((PyObject *)Py_None); - - /* "msgpack/_msgpack.pyx":306 - * def __init__(self, file_like=None, Py_ssize_t read_size=1024*1024, bint use_list=0, - * object object_hook=None, object list_hook=None, - * encoding=None, unicode_errors='strict'): # <<<<<<<<<<<<<< - * self.use_list = use_list - * self.file_like = file_like - */ - values[5] = ((PyObject *)Py_None); - values[6] = ((PyObject *)__pyx_n_s__strict); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__file_like); - if (value) { values[0] = value; kw_args--; } - } - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__read_size); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_list); - if (value) { values[2] = value; kw_args--; } - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__object_hook); - if (value) { values[3] = value; kw_args--; } - } - case 4: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__list_hook); - if (value) { values[4] = value; kw_args--; } - } - case 5: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__encoding); - if (value) { values[5] = value; kw_args--; } - } - case 6: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__unicode_errors); - if (value) { values[6] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_file_like = values[0]; - if (values[1]) { - __pyx_v_read_size = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_read_size == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_read_size = ((Py_ssize_t)1048576); - } - if (values[2]) { - __pyx_v_use_list = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_use_list == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_use_list = ((int)0); - } - __pyx_v_object_hook = values[3]; - __pyx_v_list_hook = values[4]; - __pyx_v_encoding = values[5]; - __pyx_v_unicode_errors = values[6]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("msgpack._msgpack.Unpacker.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - - /* "msgpack/_msgpack.pyx":307 - * object object_hook=None, object list_hook=None, - * encoding=None, unicode_errors='strict'): - * self.use_list = use_list # <<<<<<<<<<<<<< - * self.file_like = file_like - * if file_like: - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->use_list = __pyx_v_use_list; - - /* "msgpack/_msgpack.pyx":308 - * encoding=None, unicode_errors='strict'): - * self.use_list = use_list - * self.file_like = file_like # <<<<<<<<<<<<<< - * if file_like: - * self.file_like_read = file_like.read - */ - __Pyx_INCREF(__pyx_v_file_like); - __Pyx_GIVEREF(__pyx_v_file_like); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->file_like); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->file_like); - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->file_like = __pyx_v_file_like; - - /* "msgpack/_msgpack.pyx":309 - * self.use_list = use_list - * self.file_like = file_like - * if file_like: # <<<<<<<<<<<<<< - * self.file_like_read = file_like.read - * if not PyCallable_Check(self.file_like_read): - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_file_like); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":310 - * self.file_like = file_like - * if file_like: - * self.file_like_read = file_like.read # <<<<<<<<<<<<<< - * if not PyCallable_Check(self.file_like_read): - * raise ValueError("`file_like.read` must be a callable.") - */ - __pyx_t_2 = PyObject_GetAttr(__pyx_v_file_like, __pyx_n_s__read); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->file_like_read); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->file_like_read); - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->file_like_read = __pyx_t_2; - __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":311 - * if file_like: - * self.file_like_read = file_like.read - * if not PyCallable_Check(self.file_like_read): # <<<<<<<<<<<<<< - * raise ValueError("`file_like.read` must be a callable.") - * self.read_size = read_size - */ - __pyx_t_2 = ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->file_like_read; - __Pyx_INCREF(__pyx_t_2); - __pyx_t_1 = (!PyCallable_Check(__pyx_t_2)); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":312 - * self.file_like_read = file_like.read - * if not PyCallable_Check(self.file_like_read): - * raise ValueError("`file_like.read` must be a callable.") # <<<<<<<<<<<<<< - * self.read_size = read_size - * self.buf = malloc(read_size) - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; - } - __pyx_L7:; - goto __pyx_L6; - } - __pyx_L6:; - - /* "msgpack/_msgpack.pyx":313 - * if not PyCallable_Check(self.file_like_read): - * raise ValueError("`file_like.read` must be a callable.") - * self.read_size = read_size # <<<<<<<<<<<<<< - * self.buf = malloc(read_size) - * if self.buf == NULL: - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->read_size = __pyx_v_read_size; - - /* "msgpack/_msgpack.pyx":314 - * raise ValueError("`file_like.read` must be a callable.") - * self.read_size = read_size - * self.buf = malloc(read_size) # <<<<<<<<<<<<<< - * if self.buf == NULL: - * raise MemoryError("Unable to allocate internal buffer.") - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->buf = ((char *)malloc(__pyx_v_read_size)); - - /* "msgpack/_msgpack.pyx":315 - * self.read_size = read_size - * self.buf = malloc(read_size) - * if self.buf == NULL: # <<<<<<<<<<<<<< - * raise MemoryError("Unable to allocate internal buffer.") - * self.buf_size = read_size - */ - __pyx_t_1 = (((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->buf == NULL); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":316 - * self.buf = malloc(read_size) - * if self.buf == NULL: - * raise MemoryError("Unable to allocate internal buffer.") # <<<<<<<<<<<<<< - * self.buf_size = read_size - * self.buf_head = 0 - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L8; - } - __pyx_L8:; - - /* "msgpack/_msgpack.pyx":317 - * if self.buf == NULL: - * raise MemoryError("Unable to allocate internal buffer.") - * self.buf_size = read_size # <<<<<<<<<<<<<< - * self.buf_head = 0 - * self.buf_tail = 0 - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->buf_size = __pyx_v_read_size; - - /* "msgpack/_msgpack.pyx":318 - * raise MemoryError("Unable to allocate internal buffer.") - * self.buf_size = read_size - * self.buf_head = 0 # <<<<<<<<<<<<<< - * self.buf_tail = 0 - * template_init(&self.ctx) - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->buf_head = 0; - - /* "msgpack/_msgpack.pyx":319 - * self.buf_size = read_size - * self.buf_head = 0 - * self.buf_tail = 0 # <<<<<<<<<<<<<< - * template_init(&self.ctx) - * self.ctx.user.use_list = use_list - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->buf_tail = 0; - - /* "msgpack/_msgpack.pyx":320 - * self.buf_head = 0 - * self.buf_tail = 0 - * template_init(&self.ctx) # <<<<<<<<<<<<<< - * self.ctx.user.use_list = use_list - * self.ctx.user.object_hook = self.ctx.user.list_hook = NULL - */ - template_init((&((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx)); - - /* "msgpack/_msgpack.pyx":321 - * self.buf_tail = 0 - * template_init(&self.ctx) - * self.ctx.user.use_list = use_list # <<<<<<<<<<<<<< - * self.ctx.user.object_hook = self.ctx.user.list_hook = NULL - * if object_hook is not None: - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.use_list = __pyx_v_use_list; - - /* "msgpack/_msgpack.pyx":322 - * template_init(&self.ctx) - * self.ctx.user.use_list = use_list - * self.ctx.user.object_hook = self.ctx.user.list_hook = NULL # <<<<<<<<<<<<<< - * if object_hook is not None: - * if not PyCallable_Check(object_hook): - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.object_hook = ((PyObject *)NULL); - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.list_hook = ((PyObject *)NULL); - - /* "msgpack/_msgpack.pyx":323 - * self.ctx.user.use_list = use_list - * self.ctx.user.object_hook = self.ctx.user.list_hook = NULL - * if object_hook is not None: # <<<<<<<<<<<<<< - * if not PyCallable_Check(object_hook): - * raise TypeError("object_hook must be a callable.") - */ - __pyx_t_1 = (__pyx_v_object_hook != Py_None); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":324 - * self.ctx.user.object_hook = self.ctx.user.list_hook = NULL - * if object_hook is not None: - * if not PyCallable_Check(object_hook): # <<<<<<<<<<<<<< - * raise TypeError("object_hook must be a callable.") - * self.ctx.user.object_hook = object_hook - */ - __pyx_t_1 = (!PyCallable_Check(__pyx_v_object_hook)); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":325 - * if object_hook is not None: - * if not PyCallable_Check(object_hook): - * raise TypeError("object_hook must be a callable.") # <<<<<<<<<<<<<< - * self.ctx.user.object_hook = object_hook - * if list_hook is not None: - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L10; - } - __pyx_L10:; - - /* "msgpack/_msgpack.pyx":326 - * if not PyCallable_Check(object_hook): - * raise TypeError("object_hook must be a callable.") - * self.ctx.user.object_hook = object_hook # <<<<<<<<<<<<<< - * if list_hook is not None: - * if not PyCallable_Check(list_hook): - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.object_hook = ((PyObject *)__pyx_v_object_hook); - goto __pyx_L9; - } - __pyx_L9:; - - /* "msgpack/_msgpack.pyx":327 - * raise TypeError("object_hook must be a callable.") - * self.ctx.user.object_hook = object_hook - * if list_hook is not None: # <<<<<<<<<<<<<< - * if not PyCallable_Check(list_hook): - * raise TypeError("list_hook must be a callable.") - */ - __pyx_t_1 = (__pyx_v_list_hook != Py_None); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":328 - * self.ctx.user.object_hook = object_hook - * if list_hook is not None: - * if not PyCallable_Check(list_hook): # <<<<<<<<<<<<<< - * raise TypeError("list_hook must be a callable.") - * self.ctx.user.list_hook = list_hook - */ - __pyx_t_1 = (!PyCallable_Check(__pyx_v_list_hook)); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":329 - * if list_hook is not None: - * if not PyCallable_Check(list_hook): - * raise TypeError("list_hook must be a callable.") # <<<<<<<<<<<<<< - * self.ctx.user.list_hook = list_hook - * if encoding is None: - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L12; - } - __pyx_L12:; - - /* "msgpack/_msgpack.pyx":330 - * if not PyCallable_Check(list_hook): - * raise TypeError("list_hook must be a callable.") - * self.ctx.user.list_hook = list_hook # <<<<<<<<<<<<<< - * if encoding is None: - * self.ctx.user.encoding = NULL - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.list_hook = ((PyObject *)__pyx_v_list_hook); - goto __pyx_L11; - } - __pyx_L11:; - - /* "msgpack/_msgpack.pyx":331 - * raise TypeError("list_hook must be a callable.") - * self.ctx.user.list_hook = list_hook - * if encoding is None: # <<<<<<<<<<<<<< - * self.ctx.user.encoding = NULL - * self.ctx.user.unicode_errors = NULL - */ - __pyx_t_1 = (__pyx_v_encoding == Py_None); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":332 - * self.ctx.user.list_hook = list_hook - * if encoding is None: - * self.ctx.user.encoding = NULL # <<<<<<<<<<<<<< - * self.ctx.user.unicode_errors = NULL - * else: - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.encoding = NULL; - - /* "msgpack/_msgpack.pyx":333 - * if encoding is None: - * self.ctx.user.encoding = NULL - * self.ctx.user.unicode_errors = NULL # <<<<<<<<<<<<<< - * else: - * if isinstance(encoding, unicode): - */ - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.unicode_errors = NULL; - goto __pyx_L13; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":335 - * self.ctx.user.unicode_errors = NULL - * else: - * if isinstance(encoding, unicode): # <<<<<<<<<<<<<< - * self._bencoding = encoding.encode('ascii') - * else: - */ - __pyx_t_2 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_encoding, __pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":336 - * else: - * if isinstance(encoding, unicode): - * self._bencoding = encoding.encode('ascii') # <<<<<<<<<<<<<< - * else: - * self._bencoding = encoding - */ - __pyx_t_2 = PyObject_GetAttr(__pyx_v_encoding, __pyx_n_s__encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_3); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_bencoding); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_bencoding); - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_bencoding = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L14; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":338 - * self._bencoding = encoding.encode('ascii') - * else: - * self._bencoding = encoding # <<<<<<<<<<<<<< - * self.ctx.user.encoding = PyBytes_AsString(self._bencoding) - * if isinstance(unicode_errors, unicode): - */ - __Pyx_INCREF(__pyx_v_encoding); - __Pyx_GIVEREF(__pyx_v_encoding); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_bencoding); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_bencoding); - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_bencoding = __pyx_v_encoding; - } - __pyx_L14:; - - /* "msgpack/_msgpack.pyx":339 - * else: - * self._bencoding = encoding - * self.ctx.user.encoding = PyBytes_AsString(self._bencoding) # <<<<<<<<<<<<<< - * if isinstance(unicode_errors, unicode): - * self._berrors = unicode_errors.encode('ascii') - */ - __pyx_t_3 = ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_bencoding; - __Pyx_INCREF(__pyx_t_3); - __pyx_t_4 = PyBytes_AsString(__pyx_t_3); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.encoding = __pyx_t_4; - - /* "msgpack/_msgpack.pyx":340 - * self._bencoding = encoding - * self.ctx.user.encoding = PyBytes_AsString(self._bencoding) - * if isinstance(unicode_errors, unicode): # <<<<<<<<<<<<<< - * self._berrors = unicode_errors.encode('ascii') - * else: - */ - __pyx_t_3 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_3); - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_unicode_errors, __pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":341 - * self.ctx.user.encoding = PyBytes_AsString(self._bencoding) - * if isinstance(unicode_errors, unicode): - * self._berrors = unicode_errors.encode('ascii') # <<<<<<<<<<<<<< - * else: - * self._berrors = unicode_errors - */ - __pyx_t_3 = PyObject_GetAttr(__pyx_v_unicode_errors, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_berrors); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_berrors); - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_berrors = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L15; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":343 - * self._berrors = unicode_errors.encode('ascii') - * else: - * self._berrors = unicode_errors # <<<<<<<<<<<<<< - * self.ctx.user.unicode_errors = PyBytes_AsString(self._berrors) - * - */ - __Pyx_INCREF(__pyx_v_unicode_errors); - __Pyx_GIVEREF(__pyx_v_unicode_errors); - __Pyx_GOTREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_berrors); - __Pyx_DECREF(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_berrors); - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_berrors = __pyx_v_unicode_errors; - } - __pyx_L15:; - - /* "msgpack/_msgpack.pyx":344 - * else: - * self._berrors = unicode_errors - * self.ctx.user.unicode_errors = PyBytes_AsString(self._berrors) # <<<<<<<<<<<<<< - * - * def feed(self, object next_bytes): - */ - __pyx_t_2 = ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->_berrors; - __Pyx_INCREF(__pyx_t_2); - __pyx_t_4 = PyBytes_AsString(__pyx_t_2); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->ctx.user.unicode_errors = __pyx_t_4; - } - __pyx_L13:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("msgpack._msgpack.Unpacker.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":346 - * self.ctx.user.unicode_errors = PyBytes_AsString(self._berrors) - * - * def feed(self, object next_bytes): # <<<<<<<<<<<<<< - * cdef char* buf - * cdef Py_ssize_t buf_len - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_3feed(PyObject *__pyx_v_self, PyObject *__pyx_v_next_bytes); /*proto*/ -static char __pyx_doc_7msgpack_8_msgpack_8Unpacker_3feed[] = "Unpacker.feed(self, next_bytes)"; -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_3feed(PyObject *__pyx_v_self, PyObject *__pyx_v_next_bytes) { - char *__pyx_v_buf; - Py_ssize_t __pyx_v_buf_len; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("feed"); - - /* "msgpack/_msgpack.pyx":349 - * cdef char* buf - * cdef Py_ssize_t buf_len - * if self.file_like is not None: # <<<<<<<<<<<<<< - * raise AssertionError( - * "unpacker.feed() is not be able to use with`file_like`.") - */ - __pyx_t_1 = (((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->file_like != Py_None); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":350 - * cdef Py_ssize_t buf_len - * if self.file_like is not None: - * raise AssertionError( # <<<<<<<<<<<<<< - * "unpacker.feed() is not be able to use with`file_like`.") - * PyObject_AsReadBuffer(next_bytes, &buf, &buf_len) - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_AssertionError, ((PyObject *)__pyx_k_tuple_28), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L5; - } - __pyx_L5:; - - /* "msgpack/_msgpack.pyx":352 - * raise AssertionError( - * "unpacker.feed() is not be able to use with`file_like`.") - * PyObject_AsReadBuffer(next_bytes, &buf, &buf_len) # <<<<<<<<<<<<<< - * self.append_buffer(buf, buf_len) - * - */ - __pyx_t_3 = PyObject_AsReadBuffer(__pyx_v_next_bytes, ((const void* *)(&__pyx_v_buf)), (&__pyx_v_buf_len)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "msgpack/_msgpack.pyx":353 - * "unpacker.feed() is not be able to use with`file_like`.") - * PyObject_AsReadBuffer(next_bytes, &buf, &buf_len) - * self.append_buffer(buf, buf_len) # <<<<<<<<<<<<<< - * - * cdef append_buffer(self, void* _buf, Py_ssize_t _buf_len): - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker *)((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->__pyx_vtab)->append_buffer(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self), __pyx_v_buf, __pyx_v_buf_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("msgpack._msgpack.Unpacker.feed", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":355 - * self.append_buffer(buf, buf_len) - * - * cdef append_buffer(self, void* _buf, Py_ssize_t _buf_len): # <<<<<<<<<<<<<< - * cdef: - * char* buf = self.buf - */ - -static PyObject *__pyx_f_7msgpack_8_msgpack_8Unpacker_append_buffer(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *__pyx_v_self, void *__pyx_v__buf, Py_ssize_t __pyx_v__buf_len) { - char *__pyx_v_buf; - size_t __pyx_v_head; - size_t __pyx_v_tail; - size_t __pyx_v_buf_size; - size_t __pyx_v_new_size; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("append_buffer"); - - /* "msgpack/_msgpack.pyx":357 - * cdef append_buffer(self, void* _buf, Py_ssize_t _buf_len): - * cdef: - * char* buf = self.buf # <<<<<<<<<<<<<< - * size_t head = self.buf_head - * size_t tail = self.buf_tail - */ - __pyx_v_buf = __pyx_v_self->buf; - - /* "msgpack/_msgpack.pyx":358 - * cdef: - * char* buf = self.buf - * size_t head = self.buf_head # <<<<<<<<<<<<<< - * size_t tail = self.buf_tail - * size_t buf_size = self.buf_size - */ - __pyx_v_head = __pyx_v_self->buf_head; - - /* "msgpack/_msgpack.pyx":359 - * char* buf = self.buf - * size_t head = self.buf_head - * size_t tail = self.buf_tail # <<<<<<<<<<<<<< - * size_t buf_size = self.buf_size - * size_t new_size - */ - __pyx_v_tail = __pyx_v_self->buf_tail; - - /* "msgpack/_msgpack.pyx":360 - * size_t head = self.buf_head - * size_t tail = self.buf_tail - * size_t buf_size = self.buf_size # <<<<<<<<<<<<<< - * size_t new_size - * - */ - __pyx_v_buf_size = __pyx_v_self->buf_size; - - /* "msgpack/_msgpack.pyx":363 - * size_t new_size - * - * if tail + _buf_len > buf_size: # <<<<<<<<<<<<<< - * if ((tail - head) + _buf_len)*2 < buf_size: - * # move to front. - */ - __pyx_t_1 = ((__pyx_v_tail + __pyx_v__buf_len) > __pyx_v_buf_size); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":364 - * - * if tail + _buf_len > buf_size: - * if ((tail - head) + _buf_len)*2 < buf_size: # <<<<<<<<<<<<<< - * # move to front. - * memmove(buf, buf + head, tail - head) - */ - __pyx_t_1 = ((((__pyx_v_tail - __pyx_v_head) + __pyx_v__buf_len) * 2) < __pyx_v_buf_size); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":366 - * if ((tail - head) + _buf_len)*2 < buf_size: - * # move to front. - * memmove(buf, buf + head, tail - head) # <<<<<<<<<<<<<< - * tail -= head - * head = 0 - */ - memmove(__pyx_v_buf, (__pyx_v_buf + __pyx_v_head), (__pyx_v_tail - __pyx_v_head)); - - /* "msgpack/_msgpack.pyx":367 - * # move to front. - * memmove(buf, buf + head, tail - head) - * tail -= head # <<<<<<<<<<<<<< - * head = 0 - * else: - */ - __pyx_v_tail = (__pyx_v_tail - __pyx_v_head); - - /* "msgpack/_msgpack.pyx":368 - * memmove(buf, buf + head, tail - head) - * tail -= head - * head = 0 # <<<<<<<<<<<<<< - * else: - * # expand buffer. - */ - __pyx_v_head = 0; - goto __pyx_L4; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":371 - * else: - * # expand buffer. - * new_size = tail + _buf_len # <<<<<<<<<<<<<< - * if new_size < buf_size*2: - * new_size = buf_size*2 - */ - __pyx_v_new_size = (__pyx_v_tail + __pyx_v__buf_len); - - /* "msgpack/_msgpack.pyx":372 - * # expand buffer. - * new_size = tail + _buf_len - * if new_size < buf_size*2: # <<<<<<<<<<<<<< - * new_size = buf_size*2 - * buf = realloc(buf, new_size) - */ - __pyx_t_1 = (__pyx_v_new_size < (__pyx_v_buf_size * 2)); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":373 - * new_size = tail + _buf_len - * if new_size < buf_size*2: - * new_size = buf_size*2 # <<<<<<<<<<<<<< - * buf = realloc(buf, new_size) - * if buf == NULL: - */ - __pyx_v_new_size = (__pyx_v_buf_size * 2); - goto __pyx_L5; - } - __pyx_L5:; - - /* "msgpack/_msgpack.pyx":374 - * if new_size < buf_size*2: - * new_size = buf_size*2 - * buf = realloc(buf, new_size) # <<<<<<<<<<<<<< - * if buf == NULL: - * # self.buf still holds old buffer and will be freed during - */ - __pyx_v_buf = ((char *)realloc(__pyx_v_buf, __pyx_v_new_size)); - - /* "msgpack/_msgpack.pyx":375 - * new_size = buf_size*2 - * buf = realloc(buf, new_size) - * if buf == NULL: # <<<<<<<<<<<<<< - * # self.buf still holds old buffer and will be freed during - * # obj destruction - */ - __pyx_t_1 = (__pyx_v_buf == NULL); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":378 - * # self.buf still holds old buffer and will be freed during - * # obj destruction - * raise MemoryError("Unable to enlarge internal buffer.") # <<<<<<<<<<<<<< - * buf_size = new_size - * - */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_MemoryError, ((PyObject *)__pyx_k_tuple_30), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; - } - __pyx_L6:; - - /* "msgpack/_msgpack.pyx":379 - * # obj destruction - * raise MemoryError("Unable to enlarge internal buffer.") - * buf_size = new_size # <<<<<<<<<<<<<< - * - * memcpy(buf + tail, (_buf), _buf_len) - */ - __pyx_v_buf_size = __pyx_v_new_size; - } - __pyx_L4:; - goto __pyx_L3; - } - __pyx_L3:; - - /* "msgpack/_msgpack.pyx":381 - * buf_size = new_size - * - * memcpy(buf + tail, (_buf), _buf_len) # <<<<<<<<<<<<<< - * self.buf = buf - * self.buf_head = head - */ - memcpy((__pyx_v_buf + __pyx_v_tail), ((char *)__pyx_v__buf), __pyx_v__buf_len); - - /* "msgpack/_msgpack.pyx":382 - * - * memcpy(buf + tail, (_buf), _buf_len) - * self.buf = buf # <<<<<<<<<<<<<< - * self.buf_head = head - * self.buf_size = buf_size - */ - __pyx_v_self->buf = __pyx_v_buf; - - /* "msgpack/_msgpack.pyx":383 - * memcpy(buf + tail, (_buf), _buf_len) - * self.buf = buf - * self.buf_head = head # <<<<<<<<<<<<<< - * self.buf_size = buf_size - * self.buf_tail = tail + _buf_len - */ - __pyx_v_self->buf_head = __pyx_v_head; - - /* "msgpack/_msgpack.pyx":384 - * self.buf = buf - * self.buf_head = head - * self.buf_size = buf_size # <<<<<<<<<<<<<< - * self.buf_tail = tail + _buf_len - * - */ - __pyx_v_self->buf_size = __pyx_v_buf_size; - - /* "msgpack/_msgpack.pyx":385 - * self.buf_head = head - * self.buf_size = buf_size - * self.buf_tail = tail + _buf_len # <<<<<<<<<<<<<< - * - * # prepare self.buf from file_like - */ - __pyx_v_self->buf_tail = (__pyx_v_tail + __pyx_v__buf_len); - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("msgpack._msgpack.Unpacker.append_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":388 - * - * # prepare self.buf from file_like - * cdef fill_buffer(self): # <<<<<<<<<<<<<< - * if self.file_like is not None: - * next_bytes = self.file_like_read(self.read_size) - */ - -static PyObject *__pyx_f_7msgpack_8_msgpack_8Unpacker_fill_buffer(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *__pyx_v_self) { - PyObject *__pyx_v_next_bytes = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - char *__pyx_t_4; - Py_ssize_t __pyx_t_5; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("fill_buffer"); - - /* "msgpack/_msgpack.pyx":389 - * # prepare self.buf from file_like - * cdef fill_buffer(self): - * if self.file_like is not None: # <<<<<<<<<<<<<< - * next_bytes = self.file_like_read(self.read_size) - * if next_bytes: - */ - __pyx_t_1 = (__pyx_v_self->file_like != Py_None); - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":390 - * cdef fill_buffer(self): - * if self.file_like is not None: - * next_bytes = self.file_like_read(self.read_size) # <<<<<<<<<<<<<< - * if next_bytes: - * self.append_buffer(PyBytes_AsString(next_bytes), - */ - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->read_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_v_self->file_like_read, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_v_next_bytes = __pyx_t_2; - __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":391 - * if self.file_like is not None: - * next_bytes = self.file_like_read(self.read_size) - * if next_bytes: # <<<<<<<<<<<<<< - * self.append_buffer(PyBytes_AsString(next_bytes), - * PyBytes_Size(next_bytes)) - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_next_bytes); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_1) { - - /* "msgpack/_msgpack.pyx":392 - * next_bytes = self.file_like_read(self.read_size) - * if next_bytes: - * self.append_buffer(PyBytes_AsString(next_bytes), # <<<<<<<<<<<<<< - * PyBytes_Size(next_bytes)) - * else: - */ - __pyx_t_4 = PyBytes_AsString(__pyx_v_next_bytes); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "msgpack/_msgpack.pyx":393 - * if next_bytes: - * self.append_buffer(PyBytes_AsString(next_bytes), - * PyBytes_Size(next_bytes)) # <<<<<<<<<<<<<< - * else: - * self.file_like = None - */ - __pyx_t_5 = PyBytes_Size(__pyx_v_next_bytes); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker *)__pyx_v_self->__pyx_vtab)->append_buffer(__pyx_v_self, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - goto __pyx_L4; - } - /*else*/ { - - /* "msgpack/_msgpack.pyx":395 - * PyBytes_Size(next_bytes)) - * else: - * self.file_like = None # <<<<<<<<<<<<<< - * - * cpdef unpack(self): - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->file_like); - __Pyx_DECREF(__pyx_v_self->file_like); - __pyx_v_self->file_like = Py_None; - } - __pyx_L4:; - goto __pyx_L3; - } - __pyx_L3:; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("msgpack._msgpack.Unpacker.fill_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_next_bytes); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":397 - * self.file_like = None - * - * cpdef unpack(self): # <<<<<<<<<<<<<< - * """unpack one object""" - * cdef int ret - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_4unpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_7msgpack_8_msgpack_8Unpacker_unpack(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *__pyx_v_self, int __pyx_skip_dispatch) { - int __pyx_v_ret; - PyObject *__pyx_v_o = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("unpack"); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overriden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__unpack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_7msgpack_8_msgpack_8Unpacker_4unpack)) { - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "msgpack/_msgpack.pyx":400 - * """unpack one object""" - * cdef int ret - * while 1: # <<<<<<<<<<<<<< - * _gc_disable() - * ret = template_execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head) - */ - while (1) { - if (!1) break; - - /* "msgpack/_msgpack.pyx":401 - * cdef int ret - * while 1: - * _gc_disable() # <<<<<<<<<<<<<< - * ret = template_execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head) - * _gc_enable() - */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___gc_disable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":402 - * while 1: - * _gc_disable() - * ret = template_execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head) # <<<<<<<<<<<<<< - * _gc_enable() - * if ret == 1: - */ - __pyx_t_3 = template_execute((&__pyx_v_self->ctx), __pyx_v_self->buf, __pyx_v_self->buf_tail, (&__pyx_v_self->buf_head)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_ret = __pyx_t_3; - - /* "msgpack/_msgpack.pyx":403 - * _gc_disable() - * ret = template_execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head) - * _gc_enable() # <<<<<<<<<<<<<< - * if ret == 1: - * o = template_data(&self.ctx) - */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s___gc_enable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":408 - * template_init(&self.ctx) - * return o - * elif ret == 0: # <<<<<<<<<<<<<< - * if self.file_like is not None: - * self.fill_buffer() - */ - switch (__pyx_v_ret) { - - /* "msgpack/_msgpack.pyx":404 - * ret = template_execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head) - * _gc_enable() - * if ret == 1: # <<<<<<<<<<<<<< - * o = template_data(&self.ctx) - * template_init(&self.ctx) - */ - case 1: - - /* "msgpack/_msgpack.pyx":405 - * _gc_enable() - * if ret == 1: - * o = template_data(&self.ctx) # <<<<<<<<<<<<<< - * template_init(&self.ctx) - * return o - */ - __pyx_t_1 = template_data((&__pyx_v_self->ctx)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_o = __pyx_t_1; - __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":406 - * if ret == 1: - * o = template_data(&self.ctx) - * template_init(&self.ctx) # <<<<<<<<<<<<<< - * return o - * elif ret == 0: - */ - template_init((&__pyx_v_self->ctx)); - - /* "msgpack/_msgpack.pyx":407 - * o = template_data(&self.ctx) - * template_init(&self.ctx) - * return o # <<<<<<<<<<<<<< - * elif ret == 0: - * if self.file_like is not None: - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_o); - __pyx_r = __pyx_v_o; - goto __pyx_L0; - break; - - /* "msgpack/_msgpack.pyx":408 - * template_init(&self.ctx) - * return o - * elif ret == 0: # <<<<<<<<<<<<<< - * if self.file_like is not None: - * self.fill_buffer() - */ - case 0: - - /* "msgpack/_msgpack.pyx":409 - * return o - * elif ret == 0: - * if self.file_like is not None: # <<<<<<<<<<<<<< - * self.fill_buffer() - * continue - */ - __pyx_t_4 = (__pyx_v_self->file_like != Py_None); - if (__pyx_t_4) { - - /* "msgpack/_msgpack.pyx":410 - * elif ret == 0: - * if self.file_like is not None: - * self.fill_buffer() # <<<<<<<<<<<<<< - * continue - * raise StopIteration("No more unpack data.") - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker *)__pyx_v_self->__pyx_vtab)->fill_buffer(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":411 - * if self.file_like is not None: - * self.fill_buffer() - * continue # <<<<<<<<<<<<<< - * raise StopIteration("No more unpack data.") - * else: - */ - goto __pyx_L3_continue; - goto __pyx_L5; - } - __pyx_L5:; - - /* "msgpack/_msgpack.pyx":412 - * self.fill_buffer() - * continue - * raise StopIteration("No more unpack data.") # <<<<<<<<<<<<<< - * else: - * raise ValueError("Unpack failed: error = %d" % (ret,)) - */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_StopIteration, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - break; - default: - - /* "msgpack/_msgpack.pyx":414 - * raise StopIteration("No more unpack data.") - * else: - * raise ValueError("Unpack failed: error = %d" % (ret,)) # <<<<<<<<<<<<<< - * - * def __iter__(self): - */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_ret); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - break; - } - __pyx_L3_continue:; - } - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("msgpack._msgpack.Unpacker.unpack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_o); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":397 - * self.file_like = None - * - * cpdef unpack(self): # <<<<<<<<<<<<<< - * """unpack one object""" - * cdef int ret - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_4unpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_7msgpack_8_msgpack_8Unpacker_4unpack[] = "Unpacker.unpack(self)\nunpack one object"; -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_4unpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("unpack"); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker *)((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->__pyx_vtab)->unpack(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("msgpack._msgpack.Unpacker.unpack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":416 - * raise ValueError("Unpack failed: error = %d" % (ret,)) - * - * def __iter__(self): # <<<<<<<<<<<<<< - * return self - * - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_5__iter__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_5__iter__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__iter__"); - - /* "msgpack/_msgpack.pyx":417 - * - * def __iter__(self): - * return self # <<<<<<<<<<<<<< - * - * def __next__(self): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self); - __pyx_r = __pyx_v_self; - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "msgpack/_msgpack.pyx":419 - * return self - * - * def __next__(self): # <<<<<<<<<<<<<< - * return self.unpack() - * - */ - -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_6__next__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pf_7msgpack_8_msgpack_8Unpacker_6__next__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__next__"); - - /* "msgpack/_msgpack.pyx":420 - * - * def __next__(self): - * return self.unpack() # <<<<<<<<<<<<<< - * - * # for debug. - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker *)((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self)->__pyx_vtab)->unpack(((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("msgpack._msgpack.Unpacker.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -static struct __pyx_vtabstruct_7msgpack_8_msgpack_Packer __pyx_vtable_7msgpack_8_msgpack_Packer; - -static PyObject *__pyx_tp_new_7msgpack_8_msgpack_Packer(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_7msgpack_8_msgpack_Packer *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_7msgpack_8_msgpack_Packer *)o); - p->__pyx_vtab = __pyx_vtabptr_7msgpack_8_msgpack_Packer; - p->_default = Py_None; Py_INCREF(Py_None); - p->_bencoding = Py_None; Py_INCREF(Py_None); - p->_berrors = Py_None; Py_INCREF(Py_None); - if (__pyx_pf_7msgpack_8_msgpack_6Packer___cinit__(o, __pyx_empty_tuple, NULL) < 0) { - Py_DECREF(o); o = 0; - } - return o; -} - -static void __pyx_tp_dealloc_7msgpack_8_msgpack_Packer(PyObject *o) { - struct __pyx_obj_7msgpack_8_msgpack_Packer *p = (struct __pyx_obj_7msgpack_8_msgpack_Packer *)o; - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pf_7msgpack_8_msgpack_6Packer_2__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } - Py_XDECREF(p->_default); - Py_XDECREF(p->_bencoding); - Py_XDECREF(p->_berrors); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_7msgpack_8_msgpack_Packer(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_7msgpack_8_msgpack_Packer *p = (struct __pyx_obj_7msgpack_8_msgpack_Packer *)o; - if (p->_default) { - e = (*v)(p->_default, a); if (e) return e; - } - if (p->_bencoding) { - e = (*v)(p->_bencoding, a); if (e) return e; - } - if (p->_berrors) { - e = (*v)(p->_berrors, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_7msgpack_8_msgpack_Packer(PyObject *o) { - struct __pyx_obj_7msgpack_8_msgpack_Packer *p = (struct __pyx_obj_7msgpack_8_msgpack_Packer *)o; - PyObject* tmp; - tmp = ((PyObject*)p->_default); - p->_default = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_bencoding); - p->_bencoding = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_berrors); - p->_berrors = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyMethodDef __pyx_methods_7msgpack_8_msgpack_Packer[] = { - {__Pyx_NAMESTR("pack"), (PyCFunction)__pyx_pf_7msgpack_8_msgpack_6Packer_3pack, METH_O, __Pyx_DOCSTR(__pyx_doc_7msgpack_8_msgpack_6Packer_3pack)}, - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_Packer = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_divide*/ - #endif - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_coerce*/ - #endif - 0, /*nb_int*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_long*/ - #else - 0, /*reserved*/ - #endif - 0, /*nb_float*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_oct*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*nb_hex*/ - #endif - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_inplace_divide*/ - #endif - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if PY_VERSION_HEX >= 0x02050000 - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_Packer = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_Packer = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_Packer = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_getbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_releasebuffer*/ - #endif -}; - -static PyTypeObject __pyx_type_7msgpack_8_msgpack_Packer = { - PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("msgpack._msgpack.Packer"), /*tp_name*/ - sizeof(struct __pyx_obj_7msgpack_8_msgpack_Packer), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_7msgpack_8_msgpack_Packer, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - 0, /*tp_repr*/ - &__pyx_tp_as_number_Packer, /*tp_as_number*/ - &__pyx_tp_as_sequence_Packer, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Packer, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Packer, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - __Pyx_DOCSTR("Packer(default=None, encoding='utf-8', unicode_errors='strict')\nMessagePack Packer\n\n usage:\n\n packer = Packer()\n astream.write(packer.pack(a))\n astream.write(packer.pack(b))\n "), /*tp_doc*/ - __pyx_tp_traverse_7msgpack_8_msgpack_Packer, /*tp_traverse*/ - __pyx_tp_clear_7msgpack_8_msgpack_Packer, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_7msgpack_8_msgpack_Packer, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_pf_7msgpack_8_msgpack_6Packer_1__init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_7msgpack_8_msgpack_Packer, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 - 0, /*tp_version_tag*/ - #endif -}; -static struct __pyx_vtabstruct_7msgpack_8_msgpack_Unpacker __pyx_vtable_7msgpack_8_msgpack_Unpacker; - -static PyObject *__pyx_tp_new_7msgpack_8_msgpack_Unpacker(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_7msgpack_8_msgpack_Unpacker *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)o); - p->__pyx_vtab = __pyx_vtabptr_7msgpack_8_msgpack_Unpacker; - p->file_like = Py_None; Py_INCREF(Py_None); - p->file_like_read = Py_None; Py_INCREF(Py_None); - p->object_hook = Py_None; Py_INCREF(Py_None); - p->_bencoding = Py_None; Py_INCREF(Py_None); - p->_berrors = Py_None; Py_INCREF(Py_None); - if (__pyx_pf_7msgpack_8_msgpack_8Unpacker___cinit__(o, __pyx_empty_tuple, NULL) < 0) { - Py_DECREF(o); o = 0; - } - return o; -} - -static void __pyx_tp_dealloc_7msgpack_8_msgpack_Unpacker(PyObject *o) { - struct __pyx_obj_7msgpack_8_msgpack_Unpacker *p = (struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)o; - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pf_7msgpack_8_msgpack_8Unpacker_1__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } - Py_XDECREF(p->file_like); - Py_XDECREF(p->file_like_read); - Py_XDECREF(p->object_hook); - Py_XDECREF(p->_bencoding); - Py_XDECREF(p->_berrors); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_7msgpack_8_msgpack_Unpacker(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_7msgpack_8_msgpack_Unpacker *p = (struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)o; - if (p->file_like) { - e = (*v)(p->file_like, a); if (e) return e; - } - if (p->file_like_read) { - e = (*v)(p->file_like_read, a); if (e) return e; - } - if (p->object_hook) { - e = (*v)(p->object_hook, a); if (e) return e; - } - if (p->_bencoding) { - e = (*v)(p->_bencoding, a); if (e) return e; - } - if (p->_berrors) { - e = (*v)(p->_berrors, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_7msgpack_8_msgpack_Unpacker(PyObject *o) { - struct __pyx_obj_7msgpack_8_msgpack_Unpacker *p = (struct __pyx_obj_7msgpack_8_msgpack_Unpacker *)o; - PyObject* tmp; - tmp = ((PyObject*)p->file_like); - p->file_like = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->file_like_read); - p->file_like_read = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->object_hook); - p->object_hook = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_bencoding); - p->_bencoding = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_berrors); - p->_berrors = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyMethodDef __pyx_methods_7msgpack_8_msgpack_Unpacker[] = { - {__Pyx_NAMESTR("feed"), (PyCFunction)__pyx_pf_7msgpack_8_msgpack_8Unpacker_3feed, METH_O, __Pyx_DOCSTR(__pyx_doc_7msgpack_8_msgpack_8Unpacker_3feed)}, - {__Pyx_NAMESTR("unpack"), (PyCFunction)__pyx_pf_7msgpack_8_msgpack_8Unpacker_4unpack, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_7msgpack_8_msgpack_8Unpacker_4unpack)}, - {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_7msgpack_8_msgpack_8Unpacker_6__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)}, - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_Unpacker = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_divide*/ - #endif - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_coerce*/ - #endif - 0, /*nb_int*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_long*/ - #else - 0, /*reserved*/ - #endif - 0, /*nb_float*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_oct*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*nb_hex*/ - #endif - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - #if PY_MAJOR_VERSION < 3 - 0, /*nb_inplace_divide*/ - #endif - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if PY_VERSION_HEX >= 0x02050000 - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_Unpacker = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_Unpacker = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_Unpacker = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_getbuffer*/ - #endif - #if PY_VERSION_HEX >= 0x02060000 - 0, /*bf_releasebuffer*/ - #endif -}; - -static PyTypeObject __pyx_type_7msgpack_8_msgpack_Unpacker = { - PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("msgpack._msgpack.Unpacker"), /*tp_name*/ - sizeof(struct __pyx_obj_7msgpack_8_msgpack_Unpacker), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_7msgpack_8_msgpack_Unpacker, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #else - 0, /*reserved*/ - #endif - 0, /*tp_repr*/ - &__pyx_tp_as_number_Unpacker, /*tp_as_number*/ - &__pyx_tp_as_sequence_Unpacker, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Unpacker, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Unpacker, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - __Pyx_DOCSTR("Unpacker(file_like=None, Py_ssize_t read_size=1048576, int use_list=0, object_hook=None, list_hook=None, encoding=None, unicode_errors='strict')\n\n Streaming unpacker.\n read_size is used like file_like.read(read_size)\n\n `file_like` is a file-like object having `.read(n)` method.\n When `Unpacker` initialized with `file_like`, unpacker reads serialized data\n from it and `.feed()` method is not usable.\n\n `read_size` is used as `file_like.read(read_size)`. (default: 1M)\n\n If `use_list` is true, msgpack list is deserialized to Python list.\n Otherwise, it is deserialized to Python tuple. (default: False)\n\n `object_hook` is same to simplejson. If it is not None, it should be callable\n and Unpacker calls it when deserializing key-value.\n\n `encoding` is encoding used for decoding msgpack bytes. If it is None (default),\n msgpack bytes is deserialized to Python bytes.\n\n `unicode_errors` is used for decoding bytes.\n\n example::\n\n unpacker = Unpacker()\n while 1:\n buf = astream.read()\n unpacker.feed(buf)\n for o in unpacker:\n do_something(o)\n "), /*tp_doc*/ - __pyx_tp_traverse_7msgpack_8_msgpack_Unpacker, /*tp_traverse*/ - __pyx_tp_clear_7msgpack_8_msgpack_Unpacker, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - __pyx_pf_7msgpack_8_msgpack_8Unpacker_5__iter__, /*tp_iter*/ - __pyx_pf_7msgpack_8_msgpack_8Unpacker_6__next__, /*tp_iternext*/ - __pyx_methods_7msgpack_8_msgpack_Unpacker, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_pf_7msgpack_8_msgpack_8Unpacker_2__init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_7msgpack_8_msgpack_Unpacker, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - #if PY_VERSION_HEX >= 0x02060000 - 0, /*tp_version_tag*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - __Pyx_NAMESTR("_msgpack"), - 0, /* m_doc */ - -1, /* m_size */ - __pyx_methods /* m_methods */, - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, - {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0}, - {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0}, - {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0}, - {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0}, - {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0}, - {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0}, - {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0}, - {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, - {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0}, - {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0}, - {&__pyx_n_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 1}, - {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, - {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0}, - {&__pyx_n_s__AssertionError, __pyx_k__AssertionError, sizeof(__pyx_k__AssertionError), 0, 0, 1, 1}, - {&__pyx_n_s__MemoryError, __pyx_k__MemoryError, sizeof(__pyx_k__MemoryError), 0, 0, 1, 1}, - {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1}, - {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1}, - {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, - {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, - {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, - {&__pyx_n_s___gc_disable, __pyx_k___gc_disable, sizeof(__pyx_k___gc_disable), 0, 0, 1, 1}, - {&__pyx_n_s___gc_enable, __pyx_k___gc_enable, sizeof(__pyx_k___gc_enable), 0, 0, 1, 1}, - {&__pyx_n_s__ascii, __pyx_k__ascii, sizeof(__pyx_k__ascii), 0, 0, 1, 1}, - {&__pyx_n_s__default, __pyx_k__default, sizeof(__pyx_k__default), 0, 0, 1, 1}, - {&__pyx_n_s__disable, __pyx_k__disable, sizeof(__pyx_k__disable), 0, 0, 1, 1}, - {&__pyx_n_s__enable, __pyx_k__enable, sizeof(__pyx_k__enable), 0, 0, 1, 1}, - {&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1}, - {&__pyx_n_s__encoding, __pyx_k__encoding, sizeof(__pyx_k__encoding), 0, 0, 1, 1}, - {&__pyx_n_s__file_like, __pyx_k__file_like, sizeof(__pyx_k__file_like), 0, 0, 1, 1}, - {&__pyx_n_s__gc, __pyx_k__gc, sizeof(__pyx_k__gc), 0, 0, 1, 1}, - {&__pyx_n_s__list_hook, __pyx_k__list_hook, sizeof(__pyx_k__list_hook), 0, 0, 1, 1}, - {&__pyx_n_s__o, __pyx_k__o, sizeof(__pyx_k__o), 0, 0, 1, 1}, - {&__pyx_n_s__object_hook, __pyx_k__object_hook, sizeof(__pyx_k__object_hook), 0, 0, 1, 1}, - {&__pyx_n_s__pack, __pyx_k__pack, sizeof(__pyx_k__pack), 0, 0, 1, 1}, - {&__pyx_n_s__packb, __pyx_k__packb, sizeof(__pyx_k__packb), 0, 0, 1, 1}, - {&__pyx_n_s__packed, __pyx_k__packed, sizeof(__pyx_k__packed), 0, 0, 1, 1}, - {&__pyx_n_s__read, __pyx_k__read, sizeof(__pyx_k__read), 0, 0, 1, 1}, - {&__pyx_n_s__read_size, __pyx_k__read_size, sizeof(__pyx_k__read_size), 0, 0, 1, 1}, - {&__pyx_n_s__stream, __pyx_k__stream, sizeof(__pyx_k__stream), 0, 0, 1, 1}, - {&__pyx_n_s__strict, __pyx_k__strict, sizeof(__pyx_k__strict), 0, 0, 1, 1}, - {&__pyx_n_s__unicode_errors, __pyx_k__unicode_errors, sizeof(__pyx_k__unicode_errors), 0, 0, 1, 1}, - {&__pyx_n_s__unpack, __pyx_k__unpack, sizeof(__pyx_k__unpack), 0, 0, 1, 1}, - {&__pyx_n_s__unpackb, __pyx_k__unpackb, sizeof(__pyx_k__unpackb), 0, 0, 1, 1}, - {&__pyx_n_s__use_list, __pyx_k__use_list, sizeof(__pyx_k__use_list), 0, 0, 1, 1}, - {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_MemoryError = __Pyx_GetName(__pyx_b, __pyx_n_s__MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_AssertionError = __Pyx_GetName(__pyx_b, __pyx_n_s__AssertionError); if (!__pyx_builtin_AssertionError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants"); - - /* "msgpack/_msgpack.pyx":58 - * self.pk.buf = malloc(buf_size); - * if self.pk.buf == NULL: - * raise MemoryError("Unable to allocate internal buffer.") # <<<<<<<<<<<<<< - * self.pk.buf_size = buf_size - * self.pk.length = 0 - */ - __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_2)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); - PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_s_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2)); - - /* "msgpack/_msgpack.pyx":65 - * if default is not None: - * if not PyCallable_Check(default): - * raise TypeError("default must be a callable.") # <<<<<<<<<<<<<< - * self._default = default - * if encoding is None: - */ - __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_5)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_4)); - PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5)); - - /* "msgpack/_msgpack.pyx":72 - * else: - * if isinstance(encoding, unicode): - * self._bencoding = encoding.encode('ascii') # <<<<<<<<<<<<<< - * else: - * self._bencoding = encoding - */ - __pyx_k_tuple_6 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_6)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii)); - PyTuple_SET_ITEM(__pyx_k_tuple_6, 0, ((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); - - /* "msgpack/_msgpack.pyx":77 - * self.encoding = PyBytes_AsString(self._bencoding) - * if isinstance(unicode_errors, unicode): - * self._berrors = unicode_errors.encode('ascii') # <<<<<<<<<<<<<< - * else: - * self._berrors = unicode_errors - */ - __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii)); - PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7)); - - /* "msgpack/_msgpack.pyx":95 - * - * if nest_limit < 0: - * raise ValueError("Too deep.") # <<<<<<<<<<<<<< - * - * if o is None: - */ - __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_10)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_9)); - PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_s_9)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_9)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10)); - - /* "msgpack/_msgpack.pyx":124 - * elif PyUnicode_Check(o): - * if not self.encoding: - * raise TypeError("Can't encode utf-8 no encoding is specified") # <<<<<<<<<<<<<< - * o = PyUnicode_AsEncodedString(o, self.encoding, self.unicode_errors) - * rawval = o - */ - __pyx_k_tuple_12 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_12)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_11)); - PyTuple_SET_ITEM(__pyx_k_tuple_12, 0, ((PyObject *)__pyx_kp_s_11)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12)); - - /* "msgpack/_msgpack.pyx":212 - * else: - * if isinstance(encoding, unicode): - * bencoding = encoding.encode('ascii') # <<<<<<<<<<<<<< - * else: - * bencoding = encoding - */ - __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_14)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii)); - PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14)); - - /* "msgpack/_msgpack.pyx":216 - * bencoding = encoding - * if isinstance(unicode_errors, unicode): - * berrors = unicode_errors.encode('ascii') # <<<<<<<<<<<<<< - * else: - * berrors = unicode_errors - */ - __pyx_k_tuple_15 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_15)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii)); - PyTuple_SET_ITEM(__pyx_k_tuple_15, 0, ((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_15)); - - /* "msgpack/_msgpack.pyx":229 - * if object_hook is not None: - * if not PyCallable_Check(object_hook): - * raise TypeError("object_hook must be a callable.") # <<<<<<<<<<<<<< - * ctx.user.object_hook = object_hook - * if list_hook is not None: - */ - __pyx_k_tuple_17 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_17)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_16)); - PyTuple_SET_ITEM(__pyx_k_tuple_17, 0, ((PyObject *)__pyx_kp_s_16)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_17)); - - /* "msgpack/_msgpack.pyx":233 - * if list_hook is not None: - * if not PyCallable_Check(list_hook): - * raise TypeError("list_hook must be a callable.") # <<<<<<<<<<<<<< - * ctx.user.list_hook = list_hook - * _gc_disable() - */ - __pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_19)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); - PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_kp_s_18)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); - - /* "msgpack/_msgpack.pyx":312 - * self.file_like_read = file_like.read - * if not PyCallable_Check(self.file_like_read): - * raise ValueError("`file_like.read` must be a callable.") # <<<<<<<<<<<<<< - * self.read_size = read_size - * self.buf = malloc(read_size) - */ - __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_21)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_20)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_kp_s_20)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); - - /* "msgpack/_msgpack.pyx":316 - * self.buf = malloc(read_size) - * if self.buf == NULL: - * raise MemoryError("Unable to allocate internal buffer.") # <<<<<<<<<<<<<< - * self.buf_size = read_size - * self.buf_head = 0 - */ - __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_22)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_1)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_kp_s_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22)); - - /* "msgpack/_msgpack.pyx":325 - * if object_hook is not None: - * if not PyCallable_Check(object_hook): - * raise TypeError("object_hook must be a callable.") # <<<<<<<<<<<<<< - * self.ctx.user.object_hook = object_hook - * if list_hook is not None: - */ - __pyx_k_tuple_23 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_23)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_16)); - PyTuple_SET_ITEM(__pyx_k_tuple_23, 0, ((PyObject *)__pyx_kp_s_16)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23)); - - /* "msgpack/_msgpack.pyx":329 - * if list_hook is not None: - * if not PyCallable_Check(list_hook): - * raise TypeError("list_hook must be a callable.") # <<<<<<<<<<<<<< - * self.ctx.user.list_hook = list_hook - * if encoding is None: - */ - __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_24)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); - PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_18)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24)); - - /* "msgpack/_msgpack.pyx":336 - * else: - * if isinstance(encoding, unicode): - * self._bencoding = encoding.encode('ascii') # <<<<<<<<<<<<<< - * else: - * self._bencoding = encoding - */ - __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_25)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); - - /* "msgpack/_msgpack.pyx":341 - * self.ctx.user.encoding = PyBytes_AsString(self._bencoding) - * if isinstance(unicode_errors, unicode): - * self._berrors = unicode_errors.encode('ascii') # <<<<<<<<<<<<<< - * else: - * self._berrors = unicode_errors - */ - __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_26)); - __Pyx_INCREF(((PyObject *)__pyx_n_s__ascii)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ascii)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26)); - - /* "msgpack/_msgpack.pyx":350 - * cdef Py_ssize_t buf_len - * if self.file_like is not None: - * raise AssertionError( # <<<<<<<<<<<<<< - * "unpacker.feed() is not be able to use with`file_like`.") - * PyObject_AsReadBuffer(next_bytes, &buf, &buf_len) - */ - __pyx_k_tuple_28 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_28)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_27)); - PyTuple_SET_ITEM(__pyx_k_tuple_28, 0, ((PyObject *)__pyx_kp_s_27)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_27)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_28)); - - /* "msgpack/_msgpack.pyx":378 - * # self.buf still holds old buffer and will be freed during - * # obj destruction - * raise MemoryError("Unable to enlarge internal buffer.") # <<<<<<<<<<<<<< - * buf_size = new_size - * - */ - __pyx_k_tuple_30 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_30)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_29)); - PyTuple_SET_ITEM(__pyx_k_tuple_30, 0, ((PyObject *)__pyx_kp_s_29)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_29)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_30)); - - /* "msgpack/_msgpack.pyx":412 - * self.fill_buffer() - * continue - * raise StopIteration("No more unpack data.") # <<<<<<<<<<<<<< - * else: - * raise ValueError("Unpack failed: error = %d" % (ret,)) - */ - __pyx_k_tuple_32 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_32)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_31)); - PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_31)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32)); - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - return 0; - __pyx_L1_error:; - return -1; -} - -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC init_msgpack(void); /*proto*/ -PyMODINIT_FUNC init_msgpack(void) -#else -PyMODINIT_FUNC PyInit__msgpack(void); /*proto*/ -PyMODINIT_FUNC PyInit__msgpack(void) -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannyDeclarations - #if CYTHON_REFNANNY - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); - if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); - } - #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__msgpack(void)"); - if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #ifdef __pyx_binding_PyCFunctionType_USED - if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_msgpack"), __pyx_methods, 0, 0, PYTHON_API_VERSION); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #if PY_MAJOR_VERSION < 3 - Py_INCREF(__pyx_m); - #endif - __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); - if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - /*--- Initialize various global constants etc. ---*/ - if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_module_is_main_msgpack___msgpack) { - if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - } - /*--- Builtin init code ---*/ - if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /*--- Constants init code ---*/ - if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /*--- Global init code ---*/ - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - __pyx_vtabptr_7msgpack_8_msgpack_Packer = &__pyx_vtable_7msgpack_8_msgpack_Packer; - __pyx_vtable_7msgpack_8_msgpack_Packer._pack = (int (*)(struct __pyx_obj_7msgpack_8_msgpack_Packer *, PyObject *, struct __pyx_opt_args_7msgpack_8_msgpack_6Packer__pack *__pyx_optional_args))__pyx_f_7msgpack_8_msgpack_6Packer__pack; - if (PyType_Ready(&__pyx_type_7msgpack_8_msgpack_Packer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7msgpack_8_msgpack_Packer.tp_dict, __pyx_vtabptr_7msgpack_8_msgpack_Packer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Packer", (PyObject *)&__pyx_type_7msgpack_8_msgpack_Packer) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_7msgpack_8_msgpack_Packer = &__pyx_type_7msgpack_8_msgpack_Packer; - __pyx_vtabptr_7msgpack_8_msgpack_Unpacker = &__pyx_vtable_7msgpack_8_msgpack_Unpacker; - __pyx_vtable_7msgpack_8_msgpack_Unpacker.append_buffer = (PyObject *(*)(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *, void *, Py_ssize_t))__pyx_f_7msgpack_8_msgpack_8Unpacker_append_buffer; - __pyx_vtable_7msgpack_8_msgpack_Unpacker.fill_buffer = (PyObject *(*)(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *))__pyx_f_7msgpack_8_msgpack_8Unpacker_fill_buffer; - __pyx_vtable_7msgpack_8_msgpack_Unpacker.unpack = (PyObject *(*)(struct __pyx_obj_7msgpack_8_msgpack_Unpacker *, int __pyx_skip_dispatch))__pyx_f_7msgpack_8_msgpack_8Unpacker_unpack; - if (PyType_Ready(&__pyx_type_7msgpack_8_msgpack_Unpacker) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_7msgpack_8_msgpack_Unpacker.tp_dict, __pyx_vtabptr_7msgpack_8_msgpack_Unpacker) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Unpacker", (PyObject *)&__pyx_type_7msgpack_8_msgpack_Unpacker) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_7msgpack_8_msgpack_Unpacker = &__pyx_type_7msgpack_8_msgpack_Unpacker; - /*--- Type import code ---*/ - __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /*--- Variable import code ---*/ - /*--- Function import code ---*/ - /*--- Execution code ---*/ - - /* "msgpack/_msgpack.pyx":13 - * from libc.stdlib cimport * - * from libc.string cimport * - * import gc # <<<<<<<<<<<<<< - * _gc_disable = gc.disable - * _gc_enable = gc.enable - */ - __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__gc), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__gc, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":14 - * from libc.string cimport * - * import gc - * _gc_disable = gc.disable # <<<<<<<<<<<<<< - * _gc_enable = gc.enable - * - */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__gc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__disable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___gc_disable, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "msgpack/_msgpack.pyx":15 - * import gc - * _gc_disable = gc.disable - * _gc_enable = gc.enable # <<<<<<<<<<<<<< - * - * cdef extern from "pack.h": - */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__gc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__enable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___gc_enable, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":36 - * int msgpack_pack_raw_body(msgpack_packer* pk, char* body, size_t l) - * - * cdef int DEFAULT_RECURSE_LIMIT=511 # <<<<<<<<<<<<<< - * - * cdef class Packer(object): - */ - __pyx_v_7msgpack_8_msgpack_DEFAULT_RECURSE_LIMIT = 511; - - /* "msgpack/_msgpack.pyx":85 - * free(self.pk.buf); - * - * cdef int _pack(self, object o, int nest_limit=DEFAULT_RECURSE_LIMIT) except -1: # <<<<<<<<<<<<<< - * cdef long long llval - * cdef unsigned long long ullval - */ - __pyx_k_8 = __pyx_v_7msgpack_8_msgpack_DEFAULT_RECURSE_LIMIT; - - /* "msgpack/_msgpack.pyx":162 - * - * - * def pack(object o, object stream, default=None, encoding='utf-8', unicode_errors='strict'): # <<<<<<<<<<<<<< - * """ - * pack an object `o` and write it to stream).""" - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7msgpack_8_msgpack_pack, NULL, __pyx_n_s_34); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__pack, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":168 - * stream.write(packer.pack(o)) - * - * def packb(object o, default=None, encoding='utf-8', unicode_errors='strict'): # <<<<<<<<<<<<<< - * """ - * pack o and return packed bytes.""" - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7msgpack_8_msgpack_1packb, NULL, __pyx_n_s_34); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__packb, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":196 - * - * - * def unpackb(object packed, object object_hook=None, object list_hook=None, bint use_list=0, encoding=None, unicode_errors="strict"): # <<<<<<<<<<<<<< - * """ - * Unpack packed_bytes to object. Returns an unpacked object.""" - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7msgpack_8_msgpack_2unpackb, NULL, __pyx_n_s_34); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__unpackb, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":246 - * - * - * def unpack(object stream, object object_hook=None, object list_hook=None, bint use_list=0, encoding=None, unicode_errors="strict"): # <<<<<<<<<<<<<< - * """ - * unpack an object from stream. - */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7msgpack_8_msgpack_3unpack, NULL, __pyx_n_s_34); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__unpack, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "msgpack/_msgpack.pyx":1 - * # coding: utf-8 # <<<<<<<<<<<<<< - * #cython: embedsignature=True - * - */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - __Pyx_AddTraceback("init msgpack._msgpack", __pyx_clineno, __pyx_lineno, __pyx_filename); - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init msgpack._msgpack"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else - return __pyx_m; - #endif -} - -/* Runtime support code */ - -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif /* CYTHON_REFNANNY */ - -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { - PyObject *result; - result = PyObject_GetAttr(dict, name); - if (!result) { - if (dict != __pyx_b) { - PyErr_Clear(); - result = PyObject_GetAttr(__pyx_b, name); - } - if (!result) { - PyErr_SetObject(PyExc_NameError, name); - } - } - return result; -} - -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%s() takes %s %"PY_FORMAT_SIZE_T"d positional argument%s (%"PY_FORMAT_SIZE_T"d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -static CYTHON_INLINE int __Pyx_CheckKeywordStrings( - PyObject *kwdict, - const char* function_name, - int kw_allowed) -{ - PyObject* key = 0; - Py_ssize_t pos = 0; - while (PyDict_Next(kwdict, &pos, &key, 0)) { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) - #else - if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) - #endif - goto invalid_keyword_type; - } - if ((!kw_allowed) && unlikely(key)) - goto invalid_keyword; - return 1; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%s() keywords must be strings", function_name); - return 0; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%s() got an unexpected keyword argument '%s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif - return 0; -} - -static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyThreadState *tstate = PyThreadState_GET(); - - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} - -static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { - PyThreadState *tstate = PyThreadState_GET(); - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} - - -#if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - /* cause is unused */ - Py_XINCREF(type); - Py_XINCREF(value); - Py_XINCREF(tb); - /* First, check the traceback argument, replacing None with NULL. */ - if (tb == Py_None) { - Py_DECREF(tb); - tb = 0; - } - else if (tb != NULL && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - /* Next, replace a missing value with None */ - if (value == NULL) { - value = Py_None; - Py_INCREF(value); - } - #if PY_VERSION_HEX < 0x02050000 - if (!PyClass_Check(type)) - #else - if (!PyType_Check(type)) - #endif - { - /* Raising an instance. The value should be a dummy. */ - if (value != Py_None) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - /* Normalize to raise , */ - Py_DECREF(value); - value = type; - #if PY_VERSION_HEX < 0x02050000 - if (PyInstance_Check(type)) { - type = (PyObject*) ((PyInstanceObject*)type)->in_class; - Py_INCREF(type); - } - else { - type = 0; - PyErr_SetString(PyExc_TypeError, - "raise: exception must be an old-style class or instance"); - goto raise_error; - } - #else - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - #endif - } - - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} - -#else /* Python 3+ */ - -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (!PyExceptionClass_Check(type)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } - - if (cause) { - PyObject *fixed_cause; - if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } - else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } - else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - if (!value) { - value = PyObject_CallObject(type, NULL); - } - PyException_SetCause(value, fixed_cause); - } - - PyErr_SetObject(type, value); - - if (tb) { - PyThreadState *tstate = PyThreadState_GET(); - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } - } - -bad: - return; -} -#endif - -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AS_STRING(kw_name)); - #endif -} - -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - } else { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { - #else - if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) { - #endif - goto invalid_keyword_type; - } else { - for (name = first_kw_arg; *name; name++) { - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) break; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - _PyString_Eq(**name, key)) break; - #endif - } - if (*name) { - values[name-argnames] = value; - } else { - /* unexpected keyword found */ - for (name=argnames; name != first_kw_arg; name++) { - if (**name == key) goto arg_passed_twice; - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - _PyString_Eq(**name, key)) goto arg_passed_twice; - #endif - } - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - } - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, **name); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%s() got an unexpected keyword argument '%s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %"PY_FORMAT_SIZE_T"d value%s to unpack", - index, (index == 1) ? "" : "s"); -} - -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %"PY_FORMAT_SIZE_T"d)", expected); -} - -static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { - if (unlikely(retval)) { - Py_DECREF(retval); - __Pyx_RaiseTooManyValuesError(expected); - return -1; - } else if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { - PyErr_Clear(); - return 0; - } else { - return -1; - } - } - return 0; -} - -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) { - PyObject *py_import = 0; - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - py_import = __Pyx_GetAttrString(__pyx_b, "__import__"); - if (!py_import) - goto bad; - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - #if PY_VERSION_HEX >= 0x02050000 - { - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - } - #else - if (level>0) { - PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4."); - goto bad; - } - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, NULL); - #endif -bad: - Py_XDECREF(empty_list); - Py_XDECREF(py_import); - Py_XDECREF(empty_dict); - return module; -} - -static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { - const unsigned char neg_one = (unsigned char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned char" : - "value too large to convert to unsigned char"); - } - return (unsigned char)-1; - } - return (unsigned char)val; - } - return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) { - const unsigned short neg_one = (unsigned short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned short" : - "value too large to convert to unsigned short"); - } - return (unsigned short)-1; - } - return (unsigned short)val; - } - return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) { - const unsigned int neg_one = (unsigned int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(unsigned int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(unsigned int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to unsigned int" : - "value too large to convert to unsigned int"); - } - return (unsigned int)-1; - } - return (unsigned int)val; - } - return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x); -} - -static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) { - const char neg_one = (char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to char" : - "value too large to convert to char"); - } - return (char)-1; - } - return (char)val; - } - return (char)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) { - const short neg_one = (short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to short" : - "value too large to convert to short"); - } - return (short)-1; - } - return (short)val; - } - return (short)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) { - const int neg_one = (int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to int" : - "value too large to convert to int"); - } - return (int)-1; - } - return (int)val; - } - return (int)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) { - const signed char neg_one = (signed char)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed char) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed char)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed char" : - "value too large to convert to signed char"); - } - return (signed char)-1; - } - return (signed char)val; - } - return (signed char)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) { - const signed short neg_one = (signed short)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed short) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed short)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed short" : - "value too large to convert to signed short"); - } - return (signed short)-1; - } - return (signed short)val; - } - return (signed short)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) { - const signed int neg_one = (signed int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(signed int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(signed int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to signed int" : - "value too large to convert to signed int"); - } - return (signed int)-1; - } - return (signed int)val; - } - return (signed int)__Pyx_PyInt_AsSignedLong(x); -} - -static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) { - const int neg_one = (int)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; - if (sizeof(int) < sizeof(long)) { - long val = __Pyx_PyInt_AsLong(x); - if (unlikely(val != (long)(int)val)) { - if (!unlikely(val == -1 && PyErr_Occurred())) { - PyErr_SetString(PyExc_OverflowError, - (is_unsigned && unlikely(val < 0)) ? - "can't convert negative value to int" : - "value too large to convert to int"); - } - return (int)-1; - } - return (int)val; - } - return (int)__Pyx_PyInt_AsLong(x); -} - -static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) { - const unsigned long neg_one = (unsigned long)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long)-1; - } - return (unsigned long)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned long"); - return (unsigned long)-1; - } - return (unsigned long)PyLong_AsUnsignedLong(x); - } else { - return (unsigned long)PyLong_AsLong(x); - } - } else { - unsigned long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (unsigned long)-1; - val = __Pyx_PyInt_AsUnsignedLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) { - const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned PY_LONG_LONG"); - return (unsigned PY_LONG_LONG)-1; - } - return (unsigned PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to unsigned PY_LONG_LONG"); - return (unsigned PY_LONG_LONG)-1; - } - return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { - return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x); - } - } else { - unsigned PY_LONG_LONG val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (unsigned PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsUnsignedLongLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) { - const long neg_one = (long)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long)-1; - } - return (long)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long)-1; - } - return (long)PyLong_AsUnsignedLong(x); - } else { - return (long)PyLong_AsLong(x); - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (long)-1; - val = __Pyx_PyInt_AsLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) { - const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to PY_LONG_LONG"); - return (PY_LONG_LONG)-1; - } - return (PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to PY_LONG_LONG"); - return (PY_LONG_LONG)-1; - } - return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { - return (PY_LONG_LONG)PyLong_AsLongLong(x); - } - } else { - PY_LONG_LONG val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsLongLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) { - const signed long neg_one = (signed long)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed long"); - return (signed long)-1; - } - return (signed long)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed long"); - return (signed long)-1; - } - return (signed long)PyLong_AsUnsignedLong(x); - } else { - return (signed long)PyLong_AsLong(x); - } - } else { - signed long val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (signed long)-1; - val = __Pyx_PyInt_AsSignedLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) { - const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0; - const int is_unsigned = neg_one > const_zero; -#if PY_VERSION_HEX < 0x03000000 - if (likely(PyInt_Check(x))) { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed PY_LONG_LONG"); - return (signed PY_LONG_LONG)-1; - } - return (signed PY_LONG_LONG)val; - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { - if (unlikely(Py_SIZE(x) < 0)) { - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to signed PY_LONG_LONG"); - return (signed PY_LONG_LONG)-1; - } - return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x); - } else { - return (signed PY_LONG_LONG)PyLong_AsLongLong(x); - } - } else { - signed PY_LONG_LONG val; - PyObject *tmp = __Pyx_PyNumber_Int(x); - if (!tmp) return (signed PY_LONG_LONG)-1; - val = __Pyx_PyInt_AsSignedLongLong(tmp); - Py_DECREF(tmp); - return val; - } -} - -static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { - char message[200]; - PyOS_snprintf(message, sizeof(message), - "compiletime version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); - #if PY_VERSION_HEX < 0x02050000 - return PyErr_Warn(NULL, message); - #else - return PyErr_WarnEx(NULL, message, 1); - #endif - } - return 0; -} - -static int __Pyx_SetVtable(PyObject *dict, void *vtable) { -#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) - PyObject *ob = PyCapsule_New(vtable, 0, 0); -#else - PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); -#endif - if (!ob) - goto bad; - if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0) - goto bad; - Py_DECREF(ob); - return 0; -bad: - Py_XDECREF(ob); - return -1; -} - -#ifndef __PYX_HAVE_RT_ImportType -#define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, - size_t size, int strict) -{ - PyObject *py_module = 0; - PyObject *result = 0; - PyObject *py_name = 0; - char warning[200]; - - py_module = __Pyx_ImportModule(module_name); - if (!py_module) - goto bad; - #if PY_MAJOR_VERSION < 3 - py_name = PyString_FromString(class_name); - #else - py_name = PyUnicode_FromString(class_name); - #endif - if (!py_name) - goto bad; - result = PyObject_GetAttr(py_module, py_name); - Py_DECREF(py_name); - py_name = 0; - Py_DECREF(py_module); - py_module = 0; - if (!result) - goto bad; - if (!PyType_Check(result)) { - PyErr_Format(PyExc_TypeError, - "%s.%s is not a type object", - module_name, class_name); - goto bad; - } - if (!strict && ((PyTypeObject *)result)->tp_basicsize > (Py_ssize_t)size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility", - module_name, class_name); - #if PY_VERSION_HEX < 0x02050000 - if (PyErr_Warn(NULL, warning) < 0) goto bad; - #else - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - #endif - } - else if (((PyTypeObject *)result)->tp_basicsize != (Py_ssize_t)size) { - PyErr_Format(PyExc_ValueError, - "%s.%s has the wrong size, try recompiling", - module_name, class_name); - goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(py_module); - Py_XDECREF(result); - return NULL; -} -#endif - -#ifndef __PYX_HAVE_RT_ImportModule -#define __PYX_HAVE_RT_ImportModule -static PyObject *__Pyx_ImportModule(const char *name) { - PyObject *py_name = 0; - PyObject *py_module = 0; - - #if PY_MAJOR_VERSION < 3 - py_name = PyString_FromString(name); - #else - py_name = PyUnicode_FromString(name); - #endif - if (!py_name) - goto bad; - py_module = PyImport_Import(py_name); - Py_DECREF(py_name); - return py_module; -bad: - Py_XDECREF(py_name); - return 0; -} -#endif - -#include "compile.h" -#include "frameobject.h" -#include "traceback.h" - -static void __Pyx_AddTraceback(const char *funcname, int __pyx_clineno, - int __pyx_lineno, const char *__pyx_filename) { - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - PyObject *py_globals = 0; - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(__pyx_filename); - #else - py_srcfile = PyUnicode_FromString(__pyx_filename); - #endif - if (!py_srcfile) goto bad; - if (__pyx_clineno) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_globals = PyModule_GetDict(__pyx_m); - if (!py_globals) goto bad; - py_code = PyCode_New( - 0, /*int argcount,*/ - #if PY_MAJOR_VERSION >= 3 - 0, /*int kwonlyargcount,*/ - #endif - 0, /*int nlocals,*/ - 0, /*int stacksize,*/ - 0, /*int flags,*/ - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - __pyx_lineno, /*int firstlineno,*/ - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - if (!py_code) goto bad; - py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - py_globals, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - py_frame->f_lineno = __pyx_lineno; - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else /* Python 3+ has unicode identifiers */ - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - ++t; - } - return 0; -} - -/* Type Conversion Functions */ - -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} - -static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { - PyNumberMethods *m; - const char *name = NULL; - PyObject *res = NULL; -#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(x) || PyLong_Check(x)) -#else - if (PyLong_Check(x)) -#endif - return Py_INCREF(x), x; - m = Py_TYPE(x)->tp_as_number; -#if PY_VERSION_HEX < 0x03000000 - if (m && m->nb_int) { - name = "int"; - res = PyNumber_Int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = PyNumber_Long(x); - } -#else - if (m && m->nb_int) { - name = "int"; - res = PyNumber_Long(x); - } -#endif - if (res) { -#if PY_VERSION_HEX < 0x03000000 - if (!PyInt_Check(res) && !PyLong_Check(res)) { -#else - if (!PyLong_Check(res)) { -#endif - PyErr_Format(PyExc_TypeError, - "__%s__ returned non-%s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} - -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject* x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} - -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { -#if PY_VERSION_HEX < 0x02050000 - if (ival <= LONG_MAX) - return PyInt_FromLong((long)ival); - else { - unsigned char *bytes = (unsigned char *) &ival; - int one = 1; int little = (int)*(unsigned char*)&one; - return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0); - } -#else - return PyInt_FromSize_t(ival); -#endif -} - -static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) { - unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x); - if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) { - return (size_t)-1; - } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) { - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to size_t"); - return (size_t)-1; - } - return (size_t)val; -} - - -#endif /* Py_PYTHON_H */ diff --git a/salt/msgpack/_msgpack.pyx b/salt/msgpack/_msgpack.pyx deleted file mode 100644 index 7a8174664567..000000000000 --- a/salt/msgpack/_msgpack.pyx +++ /dev/null @@ -1,427 +0,0 @@ -# coding: utf-8 -#cython: embedsignature=True - -from cpython cimport * -cdef extern from "Python.h": - ctypedef char* const_char_ptr "const char*" - ctypedef char* const_void_ptr "const void*" - ctypedef struct PyObject - cdef int PyObject_AsReadBuffer(object o, const_void_ptr* buff, Py_ssize_t* buf_len) except -1 - -from libc.stdlib cimport * -from libc.string cimport * -import gc -_gc_disable = gc.disable -_gc_enable = gc.enable - -cdef extern from "pack.h": - struct msgpack_packer: - char* buf - size_t length - size_t buf_size - - int msgpack_pack_int(msgpack_packer* pk, int d) - int msgpack_pack_nil(msgpack_packer* pk) - int msgpack_pack_true(msgpack_packer* pk) - int msgpack_pack_false(msgpack_packer* pk) - int msgpack_pack_long(msgpack_packer* pk, long d) - int msgpack_pack_long_long(msgpack_packer* pk, long long d) - int msgpack_pack_unsigned_long_long(msgpack_packer* pk, unsigned long long d) - int msgpack_pack_double(msgpack_packer* pk, double d) - int msgpack_pack_array(msgpack_packer* pk, size_t l) - int msgpack_pack_map(msgpack_packer* pk, size_t l) - int msgpack_pack_raw(msgpack_packer* pk, size_t l) - int msgpack_pack_raw_body(msgpack_packer* pk, char* body, size_t l) - -cdef int DEFAULT_RECURSE_LIMIT=511 - -cdef class Packer(object): - """MessagePack Packer - - usage: - - packer = Packer() - astream.write(packer.pack(a)) - astream.write(packer.pack(b)) - """ - cdef msgpack_packer pk - cdef object _default - cdef object _bencoding - cdef object _berrors - cdef char *encoding - cdef char *unicode_errors - - def __cinit__(self): - cdef int buf_size = 1024*1024 - self.pk.buf = malloc(buf_size); - if self.pk.buf == NULL: - raise MemoryError("Unable to allocate internal buffer.") - self.pk.buf_size = buf_size - self.pk.length = 0 - - def __init__(self, default=None, encoding='utf-8', unicode_errors='strict'): - if default is not None: - if not PyCallable_Check(default): - raise TypeError("default must be a callable.") - self._default = default - if encoding is None: - self.encoding = NULL - self.unicode_errors = NULL - else: - if isinstance(encoding, unicode): - self._bencoding = encoding.encode('ascii') - else: - self._bencoding = encoding - self.encoding = PyBytes_AsString(self._bencoding) - if isinstance(unicode_errors, unicode): - self._berrors = unicode_errors.encode('ascii') - else: - self._berrors = unicode_errors - self.unicode_errors = PyBytes_AsString(self._berrors) - - def __dealloc__(self): - free(self.pk.buf); - - cdef int _pack(self, object o, int nest_limit=DEFAULT_RECURSE_LIMIT) except -1: - cdef long long llval - cdef unsigned long long ullval - cdef long longval - cdef double fval - cdef char* rawval - cdef int ret - cdef dict d - - if nest_limit < 0: - raise ValueError("Too deep.") - - if o is None: - ret = msgpack_pack_nil(&self.pk) - elif isinstance(o, bool): - if o: - ret = msgpack_pack_true(&self.pk) - else: - ret = msgpack_pack_false(&self.pk) - elif PyLong_Check(o): - if o > 0: - ullval = o - ret = msgpack_pack_unsigned_long_long(&self.pk, ullval) - else: - llval = o - ret = msgpack_pack_long_long(&self.pk, llval) - elif PyInt_Check(o): - longval = o - ret = msgpack_pack_long(&self.pk, longval) - elif PyFloat_Check(o): - fval = o - ret = msgpack_pack_double(&self.pk, fval) - elif PyBytes_Check(o): - rawval = o - ret = msgpack_pack_raw(&self.pk, len(o)) - if ret == 0: - ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - elif PyUnicode_Check(o): - if not self.encoding: - raise TypeError("Can't encode utf-8 no encoding is specified") - o = PyUnicode_AsEncodedString(o, self.encoding, self.unicode_errors) - rawval = o - ret = msgpack_pack_raw(&self.pk, len(o)) - if ret == 0: - ret = msgpack_pack_raw_body(&self.pk, rawval, len(o)) - elif PyDict_Check(o): - d = o - ret = msgpack_pack_map(&self.pk, len(d)) - if ret == 0: - for k,v in d.items(): - ret = self._pack(k, nest_limit-1) - if ret != 0: break - ret = self._pack(v, nest_limit-1) - if ret != 0: break - elif PySequence_Check(o): - ret = msgpack_pack_array(&self.pk, len(o)) - if ret == 0: - for v in o: - ret = self._pack(v, nest_limit-1) - if ret != 0: break - elif self._default: - o = self._default(o) - ret = self._pack(o, nest_limit-1) - else: - raise TypeError("can't serialize %r" % (o,)) - return ret - - def pack(self, object obj): - cdef int ret - ret = self._pack(obj, DEFAULT_RECURSE_LIMIT) - if ret: - raise TypeError - buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length) - self.pk.length = 0 - return buf - - -def pack(object o, object stream, default=None, encoding='utf-8', unicode_errors='strict'): - """ - pack an object `o` and write it to stream).""" - packer = Packer(default=default, encoding=encoding, unicode_errors=unicode_errors) - stream.write(packer.pack(o)) - -def packb(object o, default=None, encoding='utf-8', unicode_errors='strict'): - """ - pack o and return packed bytes.""" - packer = Packer(default=default, encoding=encoding, unicode_errors=unicode_errors) - return packer.pack(o) - - -cdef extern from "unpack.h": - ctypedef struct msgpack_user: - int use_list - PyObject* object_hook - PyObject* list_hook - char *encoding - char *unicode_errors - - ctypedef struct template_context: - msgpack_user user - PyObject* obj - size_t count - unsigned int ct - PyObject* key - - int template_execute(template_context* ctx, const_char_ptr data, - size_t len, size_t* off) except -1 - void template_init(template_context* ctx) - object template_data(template_context* ctx) - - -def unpackb(object packed, object object_hook=None, object list_hook=None, bint use_list=0, encoding=None, unicode_errors="strict"): - """ - Unpack packed_bytes to object. Returns an unpacked object.""" - cdef template_context ctx - cdef size_t off = 0 - cdef int ret - - cdef char* buf - cdef Py_ssize_t buf_len - PyObject_AsReadBuffer(packed, &buf, &buf_len) - - if encoding is None: - enc = NULL - err = NULL - else: - if isinstance(encoding, unicode): - bencoding = encoding.encode('ascii') - else: - bencoding = encoding - if isinstance(unicode_errors, unicode): - berrors = unicode_errors.encode('ascii') - else: - berrors = unicode_errors - enc = PyBytes_AsString(bencoding) - err = PyBytes_AsString(berrors) - - template_init(&ctx) - ctx.user.use_list = use_list - ctx.user.object_hook = ctx.user.list_hook = NULL - ctx.user.encoding = enc - ctx.user.unicode_errors = err - if object_hook is not None: - if not PyCallable_Check(object_hook): - raise TypeError("object_hook must be a callable.") - ctx.user.object_hook = object_hook - if list_hook is not None: - if not PyCallable_Check(list_hook): - raise TypeError("list_hook must be a callable.") - ctx.user.list_hook = list_hook - _gc_disable() - try: - ret = template_execute(&ctx, buf, buf_len, &off) - finally: - _gc_enable() - if ret == 1: - return template_data(&ctx) - else: - return None - - -def unpack(object stream, object object_hook=None, object list_hook=None, bint use_list=0, encoding=None, unicode_errors="strict"): - """ - unpack an object from stream. - """ - return unpackb(stream.read(), use_list=use_list, - object_hook=object_hook, list_hook=list_hook, encoding=encoding, unicode_errors=unicode_errors) - -cdef class Unpacker(object): - """ - Streaming unpacker. - read_size is used like file_like.read(read_size) - - `file_like` is a file-like object having `.read(n)` method. - When `Unpacker` initialized with `file_like`, unpacker reads serialized data - from it and `.feed()` method is not usable. - - `read_size` is used as `file_like.read(read_size)`. (default: 1M) - - If `use_list` is true, msgpack list is deserialized to Python list. - Otherwise, it is deserialized to Python tuple. (default: False) - - `object_hook` is same to simplejson. If it is not None, it should be callable - and Unpacker calls it when deserializing key-value. - - `encoding` is encoding used for decoding msgpack bytes. If it is None (default), - msgpack bytes is deserialized to Python bytes. - - `unicode_errors` is used for decoding bytes. - - example:: - - unpacker = Unpacker() - while 1: - buf = astream.read() - unpacker.feed(buf) - for o in unpacker: - do_something(o) - """ - cdef template_context ctx - cdef char* buf - cdef size_t buf_size, buf_head, buf_tail - cdef object file_like - cdef object file_like_read - cdef Py_ssize_t read_size - cdef bint use_list - cdef object object_hook - cdef object _bencoding - cdef object _berrors - cdef char *encoding - cdef char *unicode_errors - - def __cinit__(self): - self.buf = NULL - - def __dealloc__(self): - free(self.buf) - self.buf = NULL - - def __init__(self, file_like=None, Py_ssize_t read_size=1024*1024, bint use_list=0, - object object_hook=None, object list_hook=None, - encoding=None, unicode_errors='strict'): - self.use_list = use_list - self.file_like = file_like - if file_like: - self.file_like_read = file_like.read - if not PyCallable_Check(self.file_like_read): - raise ValueError("`file_like.read` must be a callable.") - self.read_size = read_size - self.buf = malloc(read_size) - if self.buf == NULL: - raise MemoryError("Unable to allocate internal buffer.") - self.buf_size = read_size - self.buf_head = 0 - self.buf_tail = 0 - template_init(&self.ctx) - self.ctx.user.use_list = use_list - self.ctx.user.object_hook = self.ctx.user.list_hook = NULL - if object_hook is not None: - if not PyCallable_Check(object_hook): - raise TypeError("object_hook must be a callable.") - self.ctx.user.object_hook = object_hook - if list_hook is not None: - if not PyCallable_Check(list_hook): - raise TypeError("list_hook must be a callable.") - self.ctx.user.list_hook = list_hook - if encoding is None: - self.ctx.user.encoding = NULL - self.ctx.user.unicode_errors = NULL - else: - if isinstance(encoding, unicode): - self._bencoding = encoding.encode('ascii') - else: - self._bencoding = encoding - self.ctx.user.encoding = PyBytes_AsString(self._bencoding) - if isinstance(unicode_errors, unicode): - self._berrors = unicode_errors.encode('ascii') - else: - self._berrors = unicode_errors - self.ctx.user.unicode_errors = PyBytes_AsString(self._berrors) - - def feed(self, object next_bytes): - cdef char* buf - cdef Py_ssize_t buf_len - if self.file_like is not None: - raise AssertionError( - "unpacker.feed() is not be able to use with`file_like`.") - PyObject_AsReadBuffer(next_bytes, &buf, &buf_len) - self.append_buffer(buf, buf_len) - - cdef append_buffer(self, void* _buf, Py_ssize_t _buf_len): - cdef: - char* buf = self.buf - size_t head = self.buf_head - size_t tail = self.buf_tail - size_t buf_size = self.buf_size - size_t new_size - - if tail + _buf_len > buf_size: - if ((tail - head) + _buf_len)*2 < buf_size: - # move to front. - memmove(buf, buf + head, tail - head) - tail -= head - head = 0 - else: - # expand buffer. - new_size = tail + _buf_len - if new_size < buf_size*2: - new_size = buf_size*2 - buf = realloc(buf, new_size) - if buf == NULL: - # self.buf still holds old buffer and will be freed during - # obj destruction - raise MemoryError("Unable to enlarge internal buffer.") - buf_size = new_size - - memcpy(buf + tail, (_buf), _buf_len) - self.buf = buf - self.buf_head = head - self.buf_size = buf_size - self.buf_tail = tail + _buf_len - - # prepare self.buf from file_like - cdef fill_buffer(self): - if self.file_like is not None: - next_bytes = self.file_like_read(self.read_size) - if next_bytes: - self.append_buffer(PyBytes_AsString(next_bytes), - PyBytes_Size(next_bytes)) - else: - self.file_like = None - - cpdef unpack(self): - """unpack one object""" - cdef int ret - while 1: - _gc_disable() - ret = template_execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head) - _gc_enable() - if ret == 1: - o = template_data(&self.ctx) - template_init(&self.ctx) - return o - elif ret == 0: - if self.file_like is not None: - self.fill_buffer() - continue - raise StopIteration("No more unpack data.") - else: - raise ValueError("Unpack failed: error = %d" % (ret,)) - - def __iter__(self): - return self - - def __next__(self): - return self.unpack() - - # for debug. - #def _buf(self): - # return PyString_FromStringAndSize(self.buf, self.buf_tail) - - #def _off(self): - # return self.buf_head diff --git a/salt/msgpack/pack.h b/salt/msgpack/pack.h deleted file mode 100644 index d36b436cddcc..000000000000 --- a/salt/msgpack/pack.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * MessagePack for Python packing routine - * - * Copyright (C) 2009 Naoki INADA - * - * 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. - */ - -#include -#include -#include "sysdep.h" -#include "pack_define.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _MSC_VER -#define inline __inline -#endif - -typedef struct msgpack_packer { - char *buf; - size_t length; - size_t buf_size; -} msgpack_packer; - -typedef struct Packer Packer; - -static inline int msgpack_pack_short(msgpack_packer* pk, short d); -static inline int msgpack_pack_int(msgpack_packer* pk, int d); -static inline int msgpack_pack_long(msgpack_packer* pk, long d); -static inline int msgpack_pack_long_long(msgpack_packer* pk, long long d); -static inline int msgpack_pack_unsigned_short(msgpack_packer* pk, unsigned short d); -static inline int msgpack_pack_unsigned_int(msgpack_packer* pk, unsigned int d); -static inline int msgpack_pack_unsigned_long(msgpack_packer* pk, unsigned long d); -static inline int msgpack_pack_unsigned_long_long(msgpack_packer* pk, unsigned long long d); - -static inline int msgpack_pack_uint8(msgpack_packer* pk, uint8_t d); -static inline int msgpack_pack_uint16(msgpack_packer* pk, uint16_t d); -static inline int msgpack_pack_uint32(msgpack_packer* pk, uint32_t d); -static inline int msgpack_pack_uint64(msgpack_packer* pk, uint64_t d); -static inline int msgpack_pack_int8(msgpack_packer* pk, int8_t d); -static inline int msgpack_pack_int16(msgpack_packer* pk, int16_t d); -static inline int msgpack_pack_int32(msgpack_packer* pk, int32_t d); -static inline int msgpack_pack_int64(msgpack_packer* pk, int64_t d); - -static inline int msgpack_pack_float(msgpack_packer* pk, float d); -static inline int msgpack_pack_double(msgpack_packer* pk, double d); - -static inline int msgpack_pack_nil(msgpack_packer* pk); -static inline int msgpack_pack_true(msgpack_packer* pk); -static inline int msgpack_pack_false(msgpack_packer* pk); - -static inline int msgpack_pack_array(msgpack_packer* pk, unsigned int n); - -static inline int msgpack_pack_map(msgpack_packer* pk, unsigned int n); - -static inline int msgpack_pack_raw(msgpack_packer* pk, size_t l); -static inline int msgpack_pack_raw_body(msgpack_packer* pk, const void* b, size_t l); - -static inline int msgpack_pack_write(msgpack_packer* pk, const char *data, size_t l) -{ - char* buf = pk->buf; - size_t bs = pk->buf_size; - size_t len = pk->length; - - if (len + l > bs) { - bs = (len + l) * 2; - buf = realloc(buf, bs); - if (!buf) return -1; - } - memcpy(buf + len, data, l); - len += l; - - pk->buf = buf; - pk->buf_size = bs; - pk->length = len; - return 0; -} - -#define msgpack_pack_inline_func(name) \ - static inline int msgpack_pack ## name - -#define msgpack_pack_inline_func_cint(name) \ - static inline int msgpack_pack ## name - -#define msgpack_pack_user msgpack_packer* - -#define msgpack_pack_append_buffer(user, buf, len) \ - return msgpack_pack_write(user, (const char*)buf, len) - -#include "pack_template.h" - -#ifdef __cplusplus -} -#endif diff --git a/salt/msgpack/pack_define.h b/salt/msgpack/pack_define.h deleted file mode 100644 index f72391b7ad0a..000000000000 --- a/salt/msgpack/pack_define.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MessagePack unpacking routine template - * - * Copyright (C) 2008-2009 FURUHASHI Sadayuki - * - * 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. - */ -#ifndef MSGPACK_PACK_DEFINE_H__ -#define MSGPACK_PACK_DEFINE_H__ - -#include "sysdep.h" -#include - -#endif /* msgpack/pack_define.h */ - diff --git a/salt/msgpack/pack_template.h b/salt/msgpack/pack_template.h deleted file mode 100644 index 4b508958edc8..000000000000 --- a/salt/msgpack/pack_template.h +++ /dev/null @@ -1,686 +0,0 @@ -/* - * MessagePack packing routine template - * - * Copyright (C) 2008-2009 FURUHASHI Sadayuki - * - * 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. - */ - -#ifdef __LITTLE_ENDIAN__ -#define TAKE8_8(d) ((uint8_t*)&d)[0] -#define TAKE8_16(d) ((uint8_t*)&d)[0] -#define TAKE8_32(d) ((uint8_t*)&d)[0] -#define TAKE8_64(d) ((uint8_t*)&d)[0] -#elif __BIG_ENDIAN__ -#define TAKE8_8(d) ((uint8_t*)&d)[0] -#define TAKE8_16(d) ((uint8_t*)&d)[1] -#define TAKE8_32(d) ((uint8_t*)&d)[3] -#define TAKE8_64(d) ((uint8_t*)&d)[7] -#endif - -#ifndef msgpack_pack_inline_func -#error msgpack_pack_inline_func template is not defined -#endif - -#ifndef msgpack_pack_user -#error msgpack_pack_user type is not defined -#endif - -#ifndef msgpack_pack_append_buffer -#error msgpack_pack_append_buffer callback is not defined -#endif - - -/* - * Integer - */ - -#define msgpack_pack_real_uint8(x, d) \ -do { \ - if(d < (1<<7)) { \ - /* fixnum */ \ - msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \ - } else { \ - /* unsigned 8 */ \ - unsigned char buf[2] = {0xcc, TAKE8_8(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } \ -} while(0) - -#define msgpack_pack_real_uint16(x, d) \ -do { \ - if(d < (1<<7)) { \ - /* fixnum */ \ - msgpack_pack_append_buffer(x, &TAKE8_16(d), 1); \ - } else if(d < (1<<8)) { \ - /* unsigned 8 */ \ - unsigned char buf[2] = {0xcc, TAKE8_16(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } else { \ - /* unsigned 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } \ -} while(0) - -#define msgpack_pack_real_uint32(x, d) \ -do { \ - if(d < (1<<8)) { \ - if(d < (1<<7)) { \ - /* fixnum */ \ - msgpack_pack_append_buffer(x, &TAKE8_32(d), 1); \ - } else { \ - /* unsigned 8 */ \ - unsigned char buf[2] = {0xcc, TAKE8_32(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } \ - } else { \ - if(d < (1<<16)) { \ - /* unsigned 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } else { \ - /* unsigned 32 */ \ - unsigned char buf[5]; \ - buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \ - msgpack_pack_append_buffer(x, buf, 5); \ - } \ - } \ -} while(0) - -#define msgpack_pack_real_uint64(x, d) \ -do { \ - if(d < (1ULL<<8)) { \ - if(d < (1<<7)) { \ - /* fixnum */ \ - msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \ - } else { \ - /* unsigned 8 */ \ - unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } \ - } else { \ - if(d < (1ULL<<16)) { \ - /* signed 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } else if(d < (1ULL<<32)) { \ - /* signed 32 */ \ - unsigned char buf[5]; \ - buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \ - msgpack_pack_append_buffer(x, buf, 5); \ - } else { \ - /* signed 64 */ \ - unsigned char buf[9]; \ - buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d); \ - msgpack_pack_append_buffer(x, buf, 9); \ - } \ - } \ -} while(0) - -#define msgpack_pack_real_int8(x, d) \ -do { \ - if(d < -(1<<5)) { \ - /* signed 8 */ \ - unsigned char buf[2] = {0xd0, TAKE8_8(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } else { \ - /* fixnum */ \ - msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \ - } \ -} while(0) - -#define msgpack_pack_real_int16(x, d) \ -do { \ - if(d < -(1<<5)) { \ - if(d < -(1<<7)) { \ - /* signed 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } else { \ - /* signed 8 */ \ - unsigned char buf[2] = {0xd0, TAKE8_16(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } \ - } else if(d < (1<<7)) { \ - /* fixnum */ \ - msgpack_pack_append_buffer(x, &TAKE8_16(d), 1); \ - } else { \ - if(d < (1<<8)) { \ - /* unsigned 8 */ \ - unsigned char buf[2] = {0xcc, TAKE8_16(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } else { \ - /* unsigned 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } \ - } \ -} while(0) - -#define msgpack_pack_real_int32(x, d) \ -do { \ - if(d < -(1<<5)) { \ - if(d < -(1<<15)) { \ - /* signed 32 */ \ - unsigned char buf[5]; \ - buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d); \ - msgpack_pack_append_buffer(x, buf, 5); \ - } else if(d < -(1<<7)) { \ - /* signed 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } else { \ - /* signed 8 */ \ - unsigned char buf[2] = {0xd0, TAKE8_32(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } \ - } else if(d < (1<<7)) { \ - /* fixnum */ \ - msgpack_pack_append_buffer(x, &TAKE8_32(d), 1); \ - } else { \ - if(d < (1<<8)) { \ - /* unsigned 8 */ \ - unsigned char buf[2] = {0xcc, TAKE8_32(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } else if(d < (1<<16)) { \ - /* unsigned 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } else { \ - /* unsigned 32 */ \ - unsigned char buf[5]; \ - buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \ - msgpack_pack_append_buffer(x, buf, 5); \ - } \ - } \ -} while(0) - -#define msgpack_pack_real_int64(x, d) \ -do { \ - if(d < -(1LL<<5)) { \ - if(d < -(1LL<<15)) { \ - if(d < -(1LL<<31)) { \ - /* signed 64 */ \ - unsigned char buf[9]; \ - buf[0] = 0xd3; *(uint64_t*)&buf[1] = _msgpack_be64(d); \ - msgpack_pack_append_buffer(x, buf, 9); \ - } else { \ - /* signed 32 */ \ - unsigned char buf[5]; \ - buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d); \ - msgpack_pack_append_buffer(x, buf, 5); \ - } \ - } else { \ - if(d < -(1<<7)) { \ - /* signed 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } else { \ - /* signed 8 */ \ - unsigned char buf[2] = {0xd0, TAKE8_64(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } \ - } \ - } else if(d < (1<<7)) { \ - /* fixnum */ \ - msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \ - } else { \ - if(d < (1LL<<16)) { \ - if(d < (1<<8)) { \ - /* unsigned 8 */ \ - unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \ - msgpack_pack_append_buffer(x, buf, 2); \ - } else { \ - /* unsigned 16 */ \ - unsigned char buf[3]; \ - buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \ - msgpack_pack_append_buffer(x, buf, 3); \ - } \ - } else { \ - if(d < (1LL<<32)) { \ - /* unsigned 32 */ \ - unsigned char buf[5]; \ - buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \ - msgpack_pack_append_buffer(x, buf, 5); \ - } else { \ - /* unsigned 64 */ \ - unsigned char buf[9]; \ - buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d); \ - msgpack_pack_append_buffer(x, buf, 9); \ - } \ - } \ - } \ -} while(0) - - -#ifdef msgpack_pack_inline_func_fastint - -msgpack_pack_inline_func_fastint(_uint8)(msgpack_pack_user x, uint8_t d) -{ - unsigned char buf[2] = {0xcc, TAKE8_8(d)}; - msgpack_pack_append_buffer(x, buf, 2); -} - -msgpack_pack_inline_func_fastint(_uint16)(msgpack_pack_user x, uint16_t d) -{ - unsigned char buf[3]; - buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); - msgpack_pack_append_buffer(x, buf, 3); -} - -msgpack_pack_inline_func_fastint(_uint32)(msgpack_pack_user x, uint32_t d) -{ - unsigned char buf[5]; - buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); - msgpack_pack_append_buffer(x, buf, 5); -} - -msgpack_pack_inline_func_fastint(_uint64)(msgpack_pack_user x, uint64_t d) -{ - unsigned char buf[9]; - buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d); - msgpack_pack_append_buffer(x, buf, 9); -} - -msgpack_pack_inline_func_fastint(_int8)(msgpack_pack_user x, int8_t d) -{ - unsigned char buf[2] = {0xd0, TAKE8_8(d)}; - msgpack_pack_append_buffer(x, buf, 2); -} - -msgpack_pack_inline_func_fastint(_int16)(msgpack_pack_user x, int16_t d) -{ - unsigned char buf[3]; - buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); - msgpack_pack_append_buffer(x, buf, 3); -} - -msgpack_pack_inline_func_fastint(_int32)(msgpack_pack_user x, int32_t d) -{ - unsigned char buf[5]; - buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d); - msgpack_pack_append_buffer(x, buf, 5); -} - -msgpack_pack_inline_func_fastint(_int64)(msgpack_pack_user x, int64_t d) -{ - unsigned char buf[9]; - buf[0] = 0xd3; *(uint64_t*)&buf[1] = _msgpack_be64(d); - msgpack_pack_append_buffer(x, buf, 9); -} - -#undef msgpack_pack_inline_func_fastint -#endif - - -msgpack_pack_inline_func(_uint8)(msgpack_pack_user x, uint8_t d) -{ - msgpack_pack_real_uint8(x, d); -} - -msgpack_pack_inline_func(_uint16)(msgpack_pack_user x, uint16_t d) -{ - msgpack_pack_real_uint16(x, d); -} - -msgpack_pack_inline_func(_uint32)(msgpack_pack_user x, uint32_t d) -{ - msgpack_pack_real_uint32(x, d); -} - -msgpack_pack_inline_func(_uint64)(msgpack_pack_user x, uint64_t d) -{ - msgpack_pack_real_uint64(x, d); -} - -msgpack_pack_inline_func(_int8)(msgpack_pack_user x, int8_t d) -{ - msgpack_pack_real_int8(x, d); -} - -msgpack_pack_inline_func(_int16)(msgpack_pack_user x, int16_t d) -{ - msgpack_pack_real_int16(x, d); -} - -msgpack_pack_inline_func(_int32)(msgpack_pack_user x, int32_t d) -{ - msgpack_pack_real_int32(x, d); -} - -msgpack_pack_inline_func(_int64)(msgpack_pack_user x, int64_t d) -{ - msgpack_pack_real_int64(x, d); -} - - -#ifdef msgpack_pack_inline_func_cint - -msgpack_pack_inline_func_cint(_short)(msgpack_pack_user x, short d) -{ -#if defined(SIZEOF_SHORT) || defined(SHRT_MAX) -#if SIZEOF_SHORT == 2 || SHRT_MAX == 0x7fff - msgpack_pack_real_int16(x, d); -#elif SIZEOF_SHORT == 4 || SHRT_MAX == 0x7fffffff - msgpack_pack_real_int32(x, d); -#else - msgpack_pack_real_int64(x, d); -#endif -#else -if(sizeof(short) == 2) { - msgpack_pack_real_int16(x, d); -} else if(sizeof(short) == 4) { - msgpack_pack_real_int32(x, d); -} else { - msgpack_pack_real_int64(x, d); -} -#endif -} - -msgpack_pack_inline_func_cint(_int)(msgpack_pack_user x, int d) -{ -#if defined(SIZEOF_INT) || defined(INT_MAX) -#if SIZEOF_INT == 2 || INT_MAX == 0x7fff - msgpack_pack_real_int16(x, d); -#elif SIZEOF_INT == 4 || INT_MAX == 0x7fffffff - msgpack_pack_real_int32(x, d); -#else - msgpack_pack_real_int64(x, d); -#endif -#else -if(sizeof(int) == 2) { - msgpack_pack_real_int16(x, d); -} else if(sizeof(int) == 4) { - msgpack_pack_real_int32(x, d); -} else { - msgpack_pack_real_int64(x, d); -} -#endif -} - -msgpack_pack_inline_func_cint(_long)(msgpack_pack_user x, long d) -{ -#if defined(SIZEOF_LONG) || defined(LONG_MAX) -#if SIZEOF_LONG == 2 || LONG_MAX == 0x7fffL - msgpack_pack_real_int16(x, d); -#elif SIZEOF_LONG == 4 || LONG_MAX == 0x7fffffffL - msgpack_pack_real_int32(x, d); -#else - msgpack_pack_real_int64(x, d); -#endif -#else -if(sizeof(long) == 2) { - msgpack_pack_real_int16(x, d); -} else if(sizeof(long) == 4) { - msgpack_pack_real_int32(x, d); -} else { - msgpack_pack_real_int64(x, d); -} -#endif -} - -msgpack_pack_inline_func_cint(_long_long)(msgpack_pack_user x, long long d) -{ -#if defined(SIZEOF_LONG_LONG) || defined(LLONG_MAX) -#if SIZEOF_LONG_LONG == 2 || LLONG_MAX == 0x7fffL - msgpack_pack_real_int16(x, d); -#elif SIZEOF_LONG_LONG == 4 || LLONG_MAX == 0x7fffffffL - msgpack_pack_real_int32(x, d); -#else - msgpack_pack_real_int64(x, d); -#endif -#else -if(sizeof(long long) == 2) { - msgpack_pack_real_int16(x, d); -} else if(sizeof(long long) == 4) { - msgpack_pack_real_int32(x, d); -} else { - msgpack_pack_real_int64(x, d); -} -#endif -} - -msgpack_pack_inline_func_cint(_unsigned_short)(msgpack_pack_user x, unsigned short d) -{ -#if defined(SIZEOF_SHORT) || defined(USHRT_MAX) -#if SIZEOF_SHORT == 2 || USHRT_MAX == 0xffffU - msgpack_pack_real_uint16(x, d); -#elif SIZEOF_SHORT == 4 || USHRT_MAX == 0xffffffffU - msgpack_pack_real_uint32(x, d); -#else - msgpack_pack_real_uint64(x, d); -#endif -#else -if(sizeof(unsigned short) == 2) { - msgpack_pack_real_uint16(x, d); -} else if(sizeof(unsigned short) == 4) { - msgpack_pack_real_uint32(x, d); -} else { - msgpack_pack_real_uint64(x, d); -} -#endif -} - -msgpack_pack_inline_func_cint(_unsigned_int)(msgpack_pack_user x, unsigned int d) -{ -#if defined(SIZEOF_INT) || defined(UINT_MAX) -#if SIZEOF_INT == 2 || UINT_MAX == 0xffffU - msgpack_pack_real_uint16(x, d); -#elif SIZEOF_INT == 4 || UINT_MAX == 0xffffffffU - msgpack_pack_real_uint32(x, d); -#else - msgpack_pack_real_uint64(x, d); -#endif -#else -if(sizeof(unsigned int) == 2) { - msgpack_pack_real_uint16(x, d); -} else if(sizeof(unsigned int) == 4) { - msgpack_pack_real_uint32(x, d); -} else { - msgpack_pack_real_uint64(x, d); -} -#endif -} - -msgpack_pack_inline_func_cint(_unsigned_long)(msgpack_pack_user x, unsigned long d) -{ -#if defined(SIZEOF_LONG) || defined(ULONG_MAX) -#if SIZEOF_LONG == 2 || ULONG_MAX == 0xffffUL - msgpack_pack_real_uint16(x, d); -#elif SIZEOF_LONG == 4 || ULONG_MAX == 0xffffffffUL - msgpack_pack_real_uint32(x, d); -#else - msgpack_pack_real_uint64(x, d); -#endif -#else -if(sizeof(unsigned int) == 2) { - msgpack_pack_real_uint16(x, d); -} else if(sizeof(unsigned int) == 4) { - msgpack_pack_real_uint32(x, d); -} else { - msgpack_pack_real_uint64(x, d); -} -#endif -} - -msgpack_pack_inline_func_cint(_unsigned_long_long)(msgpack_pack_user x, unsigned long long d) -{ -#if defined(SIZEOF_LONG_LONG) || defined(ULLONG_MAX) -#if SIZEOF_LONG_LONG == 2 || ULLONG_MAX == 0xffffUL - msgpack_pack_real_uint16(x, d); -#elif SIZEOF_LONG_LONG == 4 || ULLONG_MAX == 0xffffffffUL - msgpack_pack_real_uint32(x, d); -#else - msgpack_pack_real_uint64(x, d); -#endif -#else -if(sizeof(unsigned long long) == 2) { - msgpack_pack_real_uint16(x, d); -} else if(sizeof(unsigned long long) == 4) { - msgpack_pack_real_uint32(x, d); -} else { - msgpack_pack_real_uint64(x, d); -} -#endif -} - -#undef msgpack_pack_inline_func_cint -#endif - - - -/* - * Float - */ - -msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d) -{ - union { char buf[4]; uint32_t num; } f; - unsigned char buf[5]; - *((float*)&f.buf) = d; // FIXME - buf[0] = 0xca; *(uint32_t*)&buf[1] = _msgpack_be32(f.num); - msgpack_pack_append_buffer(x, buf, 5); -} - -msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d) -{ - union { char buf[8]; uint64_t num; } f; - unsigned char buf[9]; - *((double*)&f.buf) = d; // FIXME - buf[0] = 0xcb; *(uint64_t*)&buf[1] = _msgpack_be64(f.num); - msgpack_pack_append_buffer(x, buf, 9); -} - - -/* - * Nil - */ - -msgpack_pack_inline_func(_nil)(msgpack_pack_user x) -{ - static const unsigned char d = 0xc0; - msgpack_pack_append_buffer(x, &d, 1); -} - - -/* - * Boolean - */ - -msgpack_pack_inline_func(_true)(msgpack_pack_user x) -{ - static const unsigned char d = 0xc3; - msgpack_pack_append_buffer(x, &d, 1); -} - -msgpack_pack_inline_func(_false)(msgpack_pack_user x) -{ - static const unsigned char d = 0xc2; - msgpack_pack_append_buffer(x, &d, 1); -} - - -/* - * Array - */ - -msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n) -{ - if(n < 16) { - unsigned char d = 0x90 | n; - msgpack_pack_append_buffer(x, &d, 1); - } else if(n < 65536) { - unsigned char buf[3]; - buf[0] = 0xdc; *(uint16_t*)&buf[1] = _msgpack_be16(n); - msgpack_pack_append_buffer(x, buf, 3); - } else { - unsigned char buf[5]; - buf[0] = 0xdd; *(uint32_t*)&buf[1] = _msgpack_be32(n); - msgpack_pack_append_buffer(x, buf, 5); - } -} - - -/* - * Map - */ - -msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n) -{ - if(n < 16) { - unsigned char d = 0x80 | n; - msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); - } else if(n < 65536) { - unsigned char buf[3]; - buf[0] = 0xde; *(uint16_t*)&buf[1] = _msgpack_be16(n); - msgpack_pack_append_buffer(x, buf, 3); - } else { - unsigned char buf[5]; - buf[0] = 0xdf; *(uint32_t*)&buf[1] = _msgpack_be32(n); - msgpack_pack_append_buffer(x, buf, 5); - } -} - - -/* - * Raw - */ - -msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l) -{ - if(l < 32) { - unsigned char d = 0xa0 | l; - msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); - } else if(l < 65536) { - unsigned char buf[3]; - buf[0] = 0xda; *(uint16_t*)&buf[1] = _msgpack_be16(l); - msgpack_pack_append_buffer(x, buf, 3); - } else { - unsigned char buf[5]; - buf[0] = 0xdb; *(uint32_t*)&buf[1] = _msgpack_be32(l); - msgpack_pack_append_buffer(x, buf, 5); - } -} - -msgpack_pack_inline_func(_raw_body)(msgpack_pack_user x, const void* b, size_t l) -{ - msgpack_pack_append_buffer(x, (const unsigned char*)b, l); -} - -#undef msgpack_pack_inline_func -#undef msgpack_pack_user -#undef msgpack_pack_append_buffer - -#undef TAKE8_8 -#undef TAKE8_16 -#undef TAKE8_32 -#undef TAKE8_64 - -#undef msgpack_pack_real_uint8 -#undef msgpack_pack_real_uint16 -#undef msgpack_pack_real_uint32 -#undef msgpack_pack_real_uint64 -#undef msgpack_pack_real_int8 -#undef msgpack_pack_real_int16 -#undef msgpack_pack_real_int32 -#undef msgpack_pack_real_int64 - diff --git a/salt/msgpack/sysdep.h b/salt/msgpack/sysdep.h deleted file mode 100644 index 106158ea1471..000000000000 --- a/salt/msgpack/sysdep.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * MessagePack system dependencies - * - * Copyright (C) 2008-2009 FURUHASHI Sadayuki - * - * 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. - */ -#ifndef MSGPACK_SYSDEP_H__ -#define MSGPACK_SYSDEP_H__ - - -#ifdef _MSC_VER -typedef __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -#include -#include -#include -#endif - - -#ifdef _WIN32 -typedef long _msgpack_atomic_counter_t; -#define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr) -#define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr) -#else -typedef unsigned int _msgpack_atomic_counter_t; -#define _msgpack_sync_decr_and_fetch(ptr) __sync_sub_and_fetch(ptr, 1) -#define _msgpack_sync_incr_and_fetch(ptr) __sync_add_and_fetch(ptr, 1) -#endif - - -#ifdef _WIN32 -#include -#else -#include /* __BYTE_ORDER */ -#endif - -#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define __LITTLE_ENDIAN__ -#elif __BYTE_ORDER == __BIG_ENDIAN -#define __BIG_ENDIAN__ -#endif -#endif - -#ifdef __LITTLE_ENDIAN__ - -#define _msgpack_be16(x) ntohs(x) -#define _msgpack_be32(x) ntohl(x) - -#if defined(_byteswap_uint64) -# define _msgpack_be64(x) (_byteswap_uint64(x)) -#elif defined(bswap_64) -# define _msgpack_be64(x) bswap_64(x) -#elif defined(__DARWIN_OSSwapInt64) -# define _msgpack_be64(x) __DARWIN_OSSwapInt64(x) -#else -#define _msgpack_be64(x) \ - ( ((((uint64_t)x) << 56) & 0xff00000000000000ULL ) | \ - ((((uint64_t)x) << 40) & 0x00ff000000000000ULL ) | \ - ((((uint64_t)x) << 24) & 0x0000ff0000000000ULL ) | \ - ((((uint64_t)x) << 8) & 0x000000ff00000000ULL ) | \ - ((((uint64_t)x) >> 8) & 0x00000000ff000000ULL ) | \ - ((((uint64_t)x) >> 24) & 0x0000000000ff0000ULL ) | \ - ((((uint64_t)x) >> 40) & 0x000000000000ff00ULL ) | \ - ((((uint64_t)x) >> 56) & 0x00000000000000ffULL ) ) -#endif - -#else -#define _msgpack_be16(x) (x) -#define _msgpack_be32(x) (x) -#define _msgpack_be64(x) (x) -#endif - - -#endif /* msgpack/sysdep.h */ - diff --git a/salt/msgpack/unpack.h b/salt/msgpack/unpack.h deleted file mode 100644 index 0586ca86bcb5..000000000000 --- a/salt/msgpack/unpack.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * MessagePack for Python unpacking routine - * - * Copyright (C) 2009 Naoki INADA - * - * 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. - */ - -#define MSGPACK_MAX_STACK_SIZE (1024) -#include "unpack_define.h" - -typedef struct unpack_user { - int use_list; - PyObject *object_hook; - PyObject *list_hook; - const char *encoding; - const char *unicode_errors; -} unpack_user; - - -#define msgpack_unpack_struct(name) \ - struct template ## name - -#define msgpack_unpack_func(ret, name) \ - static inline ret template ## name - -#define msgpack_unpack_callback(name) \ - template_callback ## name - -#define msgpack_unpack_object PyObject* - -#define msgpack_unpack_user unpack_user - - -struct template_context; -typedef struct template_context template_context; - -static inline msgpack_unpack_object template_callback_root(unpack_user* u) -{ - return NULL; -} - -static inline int template_callback_uint16(unpack_user* u, uint16_t d, msgpack_unpack_object* o) -{ - PyObject *p = PyInt_FromLong((long)d); - if (!p) - return -1; - *o = p; - return 0; -} -static inline int template_callback_uint8(unpack_user* u, uint8_t d, msgpack_unpack_object* o) -{ - return template_callback_uint16(u, d, o); -} - - -static inline int template_callback_uint32(unpack_user* u, uint32_t d, msgpack_unpack_object* o) -{ - PyObject *p; - if (d > LONG_MAX) { - p = PyLong_FromUnsignedLong((unsigned long)d); - } else { - p = PyInt_FromLong((long)d); - } - if (!p) - return -1; - *o = p; - return 0; -} - -static inline int template_callback_uint64(unpack_user* u, uint64_t d, msgpack_unpack_object* o) -{ - PyObject *p = PyLong_FromUnsignedLongLong(d); - if (!p) - return -1; - *o = p; - return 0; -} - -static inline int template_callback_int32(unpack_user* u, int32_t d, msgpack_unpack_object* o) -{ - PyObject *p = PyInt_FromLong(d); - if (!p) - return -1; - *o = p; - return 0; -} - -static inline int template_callback_int16(unpack_user* u, int16_t d, msgpack_unpack_object* o) -{ - return template_callback_int32(u, d, o); -} - -static inline int template_callback_int8(unpack_user* u, int8_t d, msgpack_unpack_object* o) -{ - return template_callback_int32(u, d, o); -} - -static inline int template_callback_int64(unpack_user* u, int64_t d, msgpack_unpack_object* o) -{ - PyObject *p = PyLong_FromLongLong(d); - if (!p) - return -1; - *o = p; - return 0; -} - -static inline int template_callback_double(unpack_user* u, double d, msgpack_unpack_object* o) -{ - PyObject *p = PyFloat_FromDouble(d); - if (!p) - return -1; - *o = p; - return 0; -} - -static inline int template_callback_float(unpack_user* u, float d, msgpack_unpack_object* o) -{ - return template_callback_double(u, d, o); -} - -static inline int template_callback_nil(unpack_user* u, msgpack_unpack_object* o) -{ Py_INCREF(Py_None); *o = Py_None; return 0; } - -static inline int template_callback_true(unpack_user* u, msgpack_unpack_object* o) -{ Py_INCREF(Py_True); *o = Py_True; return 0; } - -static inline int template_callback_false(unpack_user* u, msgpack_unpack_object* o) -{ Py_INCREF(Py_False); *o = Py_False; return 0; } - -static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_unpack_object* o) -{ - PyObject *p = u->use_list ? PyList_New(n) : PyTuple_New(n); - - if (!p) - return -1; - *o = p; - return 0; -} - -static inline int template_callback_array_item(unpack_user* u, unsigned int current, msgpack_unpack_object* c, msgpack_unpack_object o) -{ - if (u->use_list) - PyList_SET_ITEM(*c, current, o); - else - PyTuple_SET_ITEM(*c, current, o); - return 0; -} - -static inline int template_callback_array_end(unpack_user* u, msgpack_unpack_object* c) -{ - if (u->list_hook) { - PyObject *arglist = Py_BuildValue("(O)", *c); - *c = PyEval_CallObject(u->list_hook, arglist); - Py_DECREF(arglist); - } - return 0; -} - -static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_unpack_object* o) -{ - PyObject *p = PyDict_New(); - if (!p) - return -1; - *o = p; - return 0; -} - -static inline int template_callback_map_item(unpack_user* u, msgpack_unpack_object* c, msgpack_unpack_object k, msgpack_unpack_object v) -{ - if (PyDict_SetItem(*c, k, v) == 0) { - Py_DECREF(k); - Py_DECREF(v); - return 0; - } - return -1; -} - -static inline int template_callback_map_end(unpack_user* u, msgpack_unpack_object* c) -{ - if (u->object_hook) { - PyObject *arglist = Py_BuildValue("(O)", *c); - *c = PyEval_CallObject(u->object_hook, arglist); - Py_DECREF(arglist); - } - return 0; -} - -static inline int template_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_unpack_object* o) -{ - PyObject *py; - if(u->encoding) { - py = PyUnicode_Decode(p, l, u->encoding, u->unicode_errors); - } else { - py = PyBytes_FromStringAndSize(p, l); - } - if (!py) - return -1; - *o = py; - return 0; -} - -#include "unpack_template.h" diff --git a/salt/msgpack/unpack_define.h b/salt/msgpack/unpack_define.h deleted file mode 100644 index 63d90a8e5466..000000000000 --- a/salt/msgpack/unpack_define.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * MessagePack unpacking routine template - * - * Copyright (C) 2008-2009 FURUHASHI Sadayuki - * - * 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. - */ -#ifndef MSGPACK_UNPACK_DEFINE_H__ -#define MSGPACK_UNPACK_DEFINE_H__ - -#include "sysdep.h" -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef MSGPACK_MAX_STACK_SIZE -#define MSGPACK_MAX_STACK_SIZE 16 -#endif - - -typedef enum { - CS_HEADER = 0x00, // nil - - //CS_ = 0x01, - //CS_ = 0x02, // false - //CS_ = 0x03, // true - - //CS_ = 0x04, - //CS_ = 0x05, - //CS_ = 0x06, - //CS_ = 0x07, - - //CS_ = 0x08, - //CS_ = 0x09, - CS_FLOAT = 0x0a, - CS_DOUBLE = 0x0b, - CS_UINT_8 = 0x0c, - CS_UINT_16 = 0x0d, - CS_UINT_32 = 0x0e, - CS_UINT_64 = 0x0f, - CS_INT_8 = 0x10, - CS_INT_16 = 0x11, - CS_INT_32 = 0x12, - CS_INT_64 = 0x13, - - //CS_ = 0x14, - //CS_ = 0x15, - //CS_BIG_INT_16 = 0x16, - //CS_BIG_INT_32 = 0x17, - //CS_BIG_FLOAT_16 = 0x18, - //CS_BIG_FLOAT_32 = 0x19, - CS_RAW_16 = 0x1a, - CS_RAW_32 = 0x1b, - CS_ARRAY_16 = 0x1c, - CS_ARRAY_32 = 0x1d, - CS_MAP_16 = 0x1e, - CS_MAP_32 = 0x1f, - - //ACS_BIG_INT_VALUE, - //ACS_BIG_FLOAT_VALUE, - ACS_RAW_VALUE, -} msgpack_unpack_state; - - -typedef enum { - CT_ARRAY_ITEM, - CT_MAP_KEY, - CT_MAP_VALUE, -} msgpack_container_type; - - -#ifdef __cplusplus -} -#endif - -#endif /* msgpack/unpack_define.h */ - diff --git a/salt/msgpack/unpack_template.h b/salt/msgpack/unpack_template.h deleted file mode 100644 index 42fe3a13aa85..000000000000 --- a/salt/msgpack/unpack_template.h +++ /dev/null @@ -1,386 +0,0 @@ -/* - * MessagePack unpacking routine template - * - * Copyright (C) 2008-2009 FURUHASHI Sadayuki - * - * 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. - */ - -#ifndef msgpack_unpack_func -#error msgpack_unpack_func template is not defined -#endif - -#ifndef msgpack_unpack_callback -#error msgpack_unpack_callback template is not defined -#endif - -#ifndef msgpack_unpack_struct -#error msgpack_unpack_struct template is not defined -#endif - -#ifndef msgpack_unpack_struct_decl -#define msgpack_unpack_struct_decl(name) msgpack_unpack_struct(name) -#endif - -#ifndef msgpack_unpack_object -#error msgpack_unpack_object type is not defined -#endif - -#ifndef msgpack_unpack_user -#error msgpack_unpack_user type is not defined -#endif - -#ifndef USE_CASE_RANGE -#if !defined(_MSC_VER) -#define USE_CASE_RANGE -#endif -#endif - -msgpack_unpack_struct_decl(_stack) { - msgpack_unpack_object obj; - size_t count; - unsigned int ct; - - union { - size_t curr; - msgpack_unpack_object map_key; - }; -}; - -msgpack_unpack_struct_decl(_context) { - msgpack_unpack_user user; - unsigned int cs; - unsigned int trail; - unsigned int top; - msgpack_unpack_struct(_stack) stack[MSGPACK_MAX_STACK_SIZE]; -}; - - -msgpack_unpack_func(void, _init)(msgpack_unpack_struct(_context)* ctx) -{ - ctx->cs = CS_HEADER; - ctx->trail = 0; - ctx->top = 0; - ctx->stack[0].obj = msgpack_unpack_callback(_root)(&ctx->user); -} - -msgpack_unpack_func(msgpack_unpack_object, _data)(msgpack_unpack_struct(_context)* ctx) -{ - return (ctx)->stack[0].obj; -} - - -msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const char* data, size_t len, size_t* off) -{ - const unsigned char* p = (unsigned char*)data + *off; - const unsigned char* const pe = (unsigned char*)data + len; - const void* n = NULL; - - unsigned int trail = ctx->trail; - unsigned int cs = ctx->cs; - unsigned int top = ctx->top; - - msgpack_unpack_struct(_stack)* stack = ctx->stack; - msgpack_unpack_user* user = &ctx->user; - - msgpack_unpack_object obj; - msgpack_unpack_struct(_stack)* c = NULL; - - int ret; - - assert(len >= *off); - -#define push_simple_value(func) \ - if(msgpack_unpack_callback(func)(user, &obj) < 0) { goto _failed; } \ - goto _push -#define push_fixed_value(func, arg) \ - if(msgpack_unpack_callback(func)(user, arg, &obj) < 0) { goto _failed; } \ - goto _push -#define push_variable_value(func, base, pos, len) \ - if(msgpack_unpack_callback(func)(user, \ - (const char*)base, (const char*)pos, len, &obj) < 0) { goto _failed; } \ - goto _push - -#define again_fixed_trail(_cs, trail_len) \ - trail = trail_len; \ - cs = _cs; \ - goto _fixed_trail_again -#define again_fixed_trail_if_zero(_cs, trail_len, ifzero) \ - trail = trail_len; \ - if(trail == 0) { goto ifzero; } \ - cs = _cs; \ - goto _fixed_trail_again - -#define start_container(func, count_, ct_) \ - if(msgpack_unpack_callback(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \ - if((count_) == 0) { obj = stack[top].obj; goto _push; } \ - if(top >= MSGPACK_MAX_STACK_SIZE) { goto _failed; } \ - stack[top].ct = ct_; \ - stack[top].curr = 0; \ - stack[top].count = count_; \ - /*printf("container %d count %d stack %d\n",stack[top].obj,count_,top);*/ \ - /*printf("stack push %d\n", top);*/ \ - ++top; \ - goto _header_again - -#define NEXT_CS(p) \ - ((unsigned int)*p & 0x1f) - -#define PTR_CAST_8(ptr) (*(uint8_t*)ptr) -#define PTR_CAST_16(ptr) _msgpack_be16(*(uint16_t*)ptr) -#define PTR_CAST_32(ptr) _msgpack_be32(*(uint32_t*)ptr) -#define PTR_CAST_64(ptr) _msgpack_be64(*(uint64_t*)ptr) - -#ifdef USE_CASE_RANGE -#define SWITCH_RANGE_BEGIN switch(*p) { -#define SWITCH_RANGE(FROM, TO) case FROM ... TO: -#define SWITCH_RANGE_DEFAULT default: -#define SWITCH_RANGE_END } -#else -#define SWITCH_RANGE_BEGIN { if(0) { -#define SWITCH_RANGE(FROM, TO) } else if(FROM <= *p && *p <= TO) { -#define SWITCH_RANGE_DEFAULT } else { -#define SWITCH_RANGE_END } } -#endif - - if(p == pe) { goto _out; } - do { - switch(cs) { - case CS_HEADER: - SWITCH_RANGE_BEGIN - SWITCH_RANGE(0x00, 0x7f) // Positive Fixnum - push_fixed_value(_uint8, *(uint8_t*)p); - SWITCH_RANGE(0xe0, 0xff) // Negative Fixnum - push_fixed_value(_int8, *(int8_t*)p); - SWITCH_RANGE(0xc0, 0xdf) // Variable - switch(*p) { - case 0xc0: // nil - push_simple_value(_nil); - //case 0xc1: // string - // again_terminal_trail(NEXT_CS(p), p+1); - case 0xc2: // false - push_simple_value(_false); - case 0xc3: // true - push_simple_value(_true); - //case 0xc4: - //case 0xc5: - //case 0xc6: - //case 0xc7: - //case 0xc8: - //case 0xc9: - case 0xca: // float - case 0xcb: // double - case 0xcc: // unsigned int 8 - case 0xcd: // unsigned int 16 - case 0xce: // unsigned int 32 - case 0xcf: // unsigned int 64 - case 0xd0: // signed int 8 - case 0xd1: // signed int 16 - case 0xd2: // signed int 32 - case 0xd3: // signed int 64 - again_fixed_trail(NEXT_CS(p), 1 << (((unsigned int)*p) & 0x03)); - //case 0xd4: - //case 0xd5: - //case 0xd6: // big integer 16 - //case 0xd7: // big integer 32 - //case 0xd8: // big float 16 - //case 0xd9: // big float 32 - case 0xda: // raw 16 - case 0xdb: // raw 32 - case 0xdc: // array 16 - case 0xdd: // array 32 - case 0xde: // map 16 - case 0xdf: // map 32 - again_fixed_trail(NEXT_CS(p), 2 << (((unsigned int)*p) & 0x01)); - default: - goto _failed; - } - SWITCH_RANGE(0xa0, 0xbf) // FixRaw - again_fixed_trail_if_zero(ACS_RAW_VALUE, ((unsigned int)*p & 0x1f), _raw_zero); - SWITCH_RANGE(0x90, 0x9f) // FixArray - start_container(_array, ((unsigned int)*p) & 0x0f, CT_ARRAY_ITEM); - SWITCH_RANGE(0x80, 0x8f) // FixMap - start_container(_map, ((unsigned int)*p) & 0x0f, CT_MAP_KEY); - - SWITCH_RANGE_DEFAULT - goto _failed; - SWITCH_RANGE_END - // end CS_HEADER - - - _fixed_trail_again: - ++p; - - default: - if((size_t)(pe - p) < trail) { goto _out; } - n = p; p += trail - 1; - switch(cs) { - //case CS_ - //case CS_ - case CS_FLOAT: { - union { uint32_t num; char buf[4]; } f; - f.num = PTR_CAST_32(n); // FIXME - push_fixed_value(_float, *((float*)f.buf)); } - case CS_DOUBLE: { - union { uint64_t num; char buf[8]; } f; - f.num = PTR_CAST_64(n); // FIXME - push_fixed_value(_double, *((double*)f.buf)); } - case CS_UINT_8: - push_fixed_value(_uint8, (uint8_t)PTR_CAST_8(n)); - case CS_UINT_16: - push_fixed_value(_uint16, (uint16_t)PTR_CAST_16(n)); - case CS_UINT_32: - push_fixed_value(_uint32, (uint32_t)PTR_CAST_32(n)); - case CS_UINT_64: - push_fixed_value(_uint64, (uint64_t)PTR_CAST_64(n)); - - case CS_INT_8: - push_fixed_value(_int8, (int8_t)PTR_CAST_8(n)); - case CS_INT_16: - push_fixed_value(_int16, (int16_t)PTR_CAST_16(n)); - case CS_INT_32: - push_fixed_value(_int32, (int32_t)PTR_CAST_32(n)); - case CS_INT_64: - push_fixed_value(_int64, (int64_t)PTR_CAST_64(n)); - - //case CS_ - //case CS_ - //case CS_BIG_INT_16: - // again_fixed_trail_if_zero(ACS_BIG_INT_VALUE, (uint16_t)PTR_CAST_16(n), _big_int_zero); - //case CS_BIG_INT_32: - // again_fixed_trail_if_zero(ACS_BIG_INT_VALUE, (uint32_t)PTR_CAST_32(n), _big_int_zero); - //case ACS_BIG_INT_VALUE: - //_big_int_zero: - // // FIXME - // push_variable_value(_big_int, data, n, trail); - - //case CS_BIG_FLOAT_16: - // again_fixed_trail_if_zero(ACS_BIG_FLOAT_VALUE, (uint16_t)PTR_CAST_16(n), _big_float_zero); - //case CS_BIG_FLOAT_32: - // again_fixed_trail_if_zero(ACS_BIG_FLOAT_VALUE, (uint32_t)PTR_CAST_32(n), _big_float_zero); - //case ACS_BIG_FLOAT_VALUE: - //_big_float_zero: - // // FIXME - // push_variable_value(_big_float, data, n, trail); - - case CS_RAW_16: - again_fixed_trail_if_zero(ACS_RAW_VALUE, (uint16_t)PTR_CAST_16(n), _raw_zero); - case CS_RAW_32: - again_fixed_trail_if_zero(ACS_RAW_VALUE, (uint32_t)PTR_CAST_32(n), _raw_zero); - case ACS_RAW_VALUE: - _raw_zero: - push_variable_value(_raw, data, n, trail); - - case CS_ARRAY_16: - start_container(_array, (uint16_t)PTR_CAST_16(n), CT_ARRAY_ITEM); - case CS_ARRAY_32: - /* FIXME security guard */ - start_container(_array, (uint32_t)PTR_CAST_32(n), CT_ARRAY_ITEM); - - case CS_MAP_16: - start_container(_map, (uint16_t)PTR_CAST_16(n), CT_MAP_KEY); - case CS_MAP_32: - /* FIXME security guard */ - start_container(_map, (uint32_t)PTR_CAST_32(n), CT_MAP_KEY); - - default: - goto _failed; - } - } - -_push: - if(top == 0) { goto _finish; } - c = &stack[top-1]; - switch(c->ct) { - case CT_ARRAY_ITEM: - if(msgpack_unpack_callback(_array_item)(user, c->curr, &c->obj, obj) < 0) { goto _failed; } - if(++c->curr == c->count) { - msgpack_unpack_callback(_array_end)(user, &c->obj); - obj = c->obj; - --top; - /*printf("stack pop %d\n", top);*/ - goto _push; - } - goto _header_again; - case CT_MAP_KEY: - c->map_key = obj; - c->ct = CT_MAP_VALUE; - goto _header_again; - case CT_MAP_VALUE: - if(msgpack_unpack_callback(_map_item)(user, &c->obj, c->map_key, obj) < 0) { goto _failed; } - if(--c->count == 0) { - msgpack_unpack_callback(_map_end)(user, &c->obj); - obj = c->obj; - --top; - /*printf("stack pop %d\n", top);*/ - goto _push; - } - c->ct = CT_MAP_KEY; - goto _header_again; - - default: - goto _failed; - } - -_header_again: - cs = CS_HEADER; - ++p; - } while(p != pe); - goto _out; - - -_finish: - stack[0].obj = obj; - ++p; - ret = 1; - /*printf("-- finish --\n"); */ - goto _end; - -_failed: - /*printf("** FAILED **\n"); */ - ret = -1; - goto _end; - -_out: - ret = 0; - goto _end; - -_end: - ctx->cs = cs; - ctx->trail = trail; - ctx->top = top; - *off = p - (const unsigned char*)data; - - return ret; -} - - -#undef msgpack_unpack_func -#undef msgpack_unpack_callback -#undef msgpack_unpack_struct -#undef msgpack_unpack_object -#undef msgpack_unpack_user - -#undef push_simple_value -#undef push_fixed_value -#undef push_variable_value -#undef again_fixed_trail -#undef again_fixed_trail_if_zero -#undef start_container - -#undef NEXT_CS -#undef PTR_CAST_8 -#undef PTR_CAST_16 -#undef PTR_CAST_32 -#undef PTR_CAST_64 - diff --git a/salt/payload.py b/salt/payload.py index d2f7ee0f53d8..c1a1dc9aa2d9 100644 --- a/salt/payload.py +++ b/salt/payload.py @@ -5,7 +5,7 @@ import cPickle as pickle -import salt.msgpack as msgpack +import msgpack def package(payload): From 6f14527aaa18ca3f707523535d596acc1c8fb847 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 20:23:06 -0700 Subject: [PATCH 82/84] update version to 0.9.6 --- salt/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/version.py b/salt/version.py index 4c827bb6e5eb..88607c74c3a8 100644 --- a/salt/version.py +++ b/salt/version.py @@ -1,2 +1,2 @@ -__version_info__ = (0, 9, 5) +__version_info__ = (0, 9, 6) __version__ = '.'.join(map(str, __version_info__)) From 26b0215a2b0575c9ca75624c6f1c4ac1f08ccafc Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 20:36:16 -0700 Subject: [PATCH 83/84] Add msgpack top Mock modules --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 26aae63ea426..bad729ad15c4 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -30,7 +30,7 @@ def __getattr__(self, name): MOCK_MODULES = [ # salt core 'yaml', - 'salt.msgpack._msgpack', + 'msgpack', 'zmq', 'Crypto', 'Crypto.Cipher', From 6804c86b3a58b59f7face349a3240b4587944ce1 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Fri, 20 Jan 2012 20:45:27 -0700 Subject: [PATCH 84/84] update man pages to 0.9.6 --- doc/man/salt-call.1 | 2 +- doc/man/salt-cp.1 | 2 +- doc/man/salt-key.1 | 2 +- doc/man/salt-master.1 | 14 +- doc/man/salt-minion.1 | 14 +- doc/man/salt-run.1 | 2 +- doc/man/salt-syndic.1 | 2 +- doc/man/salt.1 | 2 +- doc/man/salt.7 | 4589 ++++++++++++++++++++++++++++++++--------- 9 files changed, 3618 insertions(+), 1011 deletions(-) diff --git a/doc/man/salt-call.1 b/doc/man/salt-call.1 index 5a435a76b791..7eced080e9d1 100644 --- a/doc/man/salt-call.1 +++ b/doc/man/salt-call.1 @@ -1,4 +1,4 @@ -.TH "SALT-CALL" "1" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT-CALL" "1" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt-call \- salt-call Documentation . diff --git a/doc/man/salt-cp.1 b/doc/man/salt-cp.1 index 71d01834d2cd..3077919cb816 100644 --- a/doc/man/salt-cp.1 +++ b/doc/man/salt-cp.1 @@ -1,4 +1,4 @@ -.TH "SALT-CP" "1" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT-CP" "1" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt-cp \- salt-cp Documentation . diff --git a/doc/man/salt-key.1 b/doc/man/salt-key.1 index 58cba2c6c43d..5b60b2fb88af 100644 --- a/doc/man/salt-key.1 +++ b/doc/man/salt-key.1 @@ -1,4 +1,4 @@ -.TH "SALT-KEY" "1" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT-KEY" "1" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt-key \- salt-key Documentation . diff --git a/doc/man/salt-master.1 b/doc/man/salt-master.1 index 067ad4e9d5cd..cbd3c47f9bc9 100644 --- a/doc/man/salt-master.1 +++ b/doc/man/salt-master.1 @@ -1,4 +1,4 @@ -.TH "SALT-MASTER" "1" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT-MASTER" "1" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt-master \- salt-master Documentation . @@ -54,6 +54,18 @@ Run the salt master as a daemon .B \-c CONFIG, \-\-config=CONFIG The master configuration file to use, the default is /etc/salt/master .UNINDENT +.INDENT 0.0 +.TP +.B \-u USER, \-\-user=USER +Specify user to run minion +.UNINDENT +.INDENT 0.0 +.TP +.B \-l LOG_LEVEL, \-\-log\-level=LOG_LEVEL +Console log level. One of \fBinfo\fP, \fBnone\fP, \fBgarbage\fP, +\fBtrace\fP, \fBwarning\fP, \fBerror\fP, \fBdebug\fP. For the logfile +settings see the config file. Default: \fBwarning\fP. +.UNINDENT .SH AUTHOR Thomas S. Hatch and many others, please see the Authors file .SH COPYRIGHT diff --git a/doc/man/salt-minion.1 b/doc/man/salt-minion.1 index ac1ed16d7059..e9155e574e31 100644 --- a/doc/man/salt-minion.1 +++ b/doc/man/salt-minion.1 @@ -1,4 +1,4 @@ -.TH "SALT-MINION" "1" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT-MINION" "1" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt-minion \- salt-minion Documentation . @@ -55,6 +55,18 @@ Run the salt minion as a daemon .B \-c CONFIG, \-\-config=CONFIG The minion configuration file to use, the default is /etc/salt/minion .UNINDENT +.INDENT 0.0 +.TP +.B \-u USER, \-\-user=USER +Specify user to run minion +.UNINDENT +.INDENT 0.0 +.TP +.B \-l LOG_LEVEL, \-\-log\-level=LOG_LEVEL +Console log level. One of \fBinfo\fP, \fBnone\fP, \fBgarbage\fP, +\fBtrace\fP, \fBwarning\fP, \fBerror\fP, \fBdebug\fP. For the logfile +settings see the config file. Default: \fBwarning\fP. +.UNINDENT .SH AUTHOR Thomas S. Hatch and many others, please see the Authors file .SH COPYRIGHT diff --git a/doc/man/salt-run.1 b/doc/man/salt-run.1 index 6c88774014b6..c7a1f2a9e5c7 100644 --- a/doc/man/salt-run.1 +++ b/doc/man/salt-run.1 @@ -1,4 +1,4 @@ -.TH "SALT-RUN" "1" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT-RUN" "1" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt-run \- salt-run Documentation . diff --git a/doc/man/salt-syndic.1 b/doc/man/salt-syndic.1 index a68f744f3426..46eb378bec41 100644 --- a/doc/man/salt-syndic.1 +++ b/doc/man/salt-syndic.1 @@ -1,4 +1,4 @@ -.TH "SALT-SYNDIC" "1" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT-SYNDIC" "1" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt-syndic \- salt-syndic Documentation . diff --git a/doc/man/salt.1 b/doc/man/salt.1 index 4756ef854d37..564c1da89f85 100644 --- a/doc/man/salt.1 +++ b/doc/man/salt.1 @@ -1,4 +1,4 @@ -.TH "SALT" "1" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT" "1" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt \- salt . diff --git a/doc/man/salt.7 b/doc/man/salt.7 index 02c10a146df9..5f086c4c7281 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -1,4 +1,4 @@ -.TH "SALT" "7" "January 14, 2012" "0.9.5" "Salt" +.TH "SALT" "7" "January 20, 2012" "0.9.6" "Salt" .SH NAME salt \- Salt Documentation . @@ -153,7 +153,7 @@ contains a viable, and transparent, AMQ broker inside the daemon. Salt uses public keys for authentication with the master daemon, then uses faster AES encryption for payload communication, this means that authentication and encryption are also built into Salt. Salt takes advantage of communication via -Python pickles, enabling fast and light network traffic. +\fI\%msgpack\fP, enabling fast and light network traffic. .SS Python client interface .sp In order to allow for simple expansion, Salt execution routines can be written @@ -233,7 +233,7 @@ repository. .SS Red Hat Enterprise Linux 5 & 6 or CentOS 5 & 6 .INDENT 0.0 .IP 1. 3 -Install the \fI\%EPEL\fP repository: +Install the \fI\%EPEL\fP repository. .IP 2. 3 Install our repository on FedoraPeople: .sp @@ -289,7 +289,7 @@ accepted you can install Salt by downloading the latest \fB.deb\fP in the .sp .nf .ft C -dpkg \-i salt\-0.9.5\&.deb +dpkg \-i salt\-0.9.6\&.deb .ft P .fi .IP "Installing ZeroMQ on Squeeze (Debian 6)" @@ -318,15 +318,15 @@ Then download and install from source: .INDENT 0.0 .IP 1. 3 Download the latest source tarball from the GitHub downloads directory for -the Salt project: \fI\%https://github.com/downloads/saltstack/salt/salt-0.9.5.tar.gz\fP +the Salt project: \fI\%https://github.com/downloads/saltstack/salt/salt-0.9.6.tar.gz\fP .IP 2. 3 Untar the tarball and run the \fBsetup.py\fP as root: .UNINDENT .sp .nf .ft C -tar xvf salt\-0.9.5\&.tar.gz -cd salt\-0.9.5 +tar xvf salt\-0.9.6\&.tar.gz +cd salt\-0.9.6 python2 setup.py install .ft P .fi @@ -347,15 +347,15 @@ cd /usr/ports/sysutils/salt && make install clean .INDENT 0.0 .IP 1. 3 Download the latest source tarball from the GitHub downloads directory for -the Salt project: \fI\%https://github.com/downloads/saltstack/salt/salt-0.9.5.tar.gz\fP +the Salt project: \fI\%https://github.com/downloads/saltstack/salt/salt-0.9.6.tar.gz\fP .IP 2. 3 Untar the tarball and run the \fBsetup.py\fP as root: .UNINDENT .sp .nf .ft C -tar xvf salt\-0.9.5\&.tar.gz -cd salt\-0.9.5 +tar xvf salt\-0.9.6\&.tar.gz +cd salt\-0.9.6 python2 setup.py install .ft P .fi @@ -393,7 +393,7 @@ Start the master in the foreground (to daemonize the process, pass the .sp .nf .ft C -salt\-master +# salt\-master .ft P .fi .IP 2. 3 @@ -402,7 +402,7 @@ Start the minion in the foreground (to daemonize the process, pass the .sp .nf .ft C -salt\-minion +# salt\-minion .ft P .fi .UNINDENT @@ -417,6 +417,12 @@ salt\-master \-\-log\-level=debug .ft P .fi .RE +.IP "Run as an unprivileged (non\-root) user?" +.sp +To run Salt as another user, specify \fB\-\-user\fP in the command +line or assign \fBuser\fP in the +\fBconfiguration file\fP. +.RE .SS Manage Salt public keys .sp Salt manages authentication with RSA public keys. The keys are managed on the @@ -1196,7 +1202,7 @@ executions to manipulating the flow of how data is handled by Salt. The minion execution modules or just \fBmodules\fP are the core to what salt is and does. These modules are found in: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/modules\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/modules\fP .sp These modules are what is called by the salt command line and the salt client api. Adding modules is done by simply adding additional python modules to the @@ -1213,7 +1219,7 @@ of execution modules and types to specific salt minions. .sp The code used to generate the Salt grains can be found here: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/grains\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/grains\fP .SS States .sp Salt supports state enforcement, this makes Salt a high speed and very efficient @@ -1221,7 +1227,7 @@ solution for system configuration management. .sp States can be easily added to Salt by dropping a new state module in: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/states\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/states\fP .SS Renderers .sp Salt states are controlled by simple data structures, these structures can be @@ -1232,7 +1238,7 @@ it. .sp The existing renderers can be found here: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/renderers\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/renderers\fP .SS Returners .sp The salt commands all produce a return value, that return value is sent to the @@ -1242,7 +1248,7 @@ from an SQL or NOSQL database, to a custom application made to use Salt. .sp The existing returners can be found here: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/returners\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/returners\fP .SS Runners .sp Sometimes a certain application can be made to execute and run from the @@ -1252,7 +1258,7 @@ act as a generic interface for encapsulating master side executions. .sp Existing Salt runners are located here: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/runners\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/runners\fP .SH MODULES .sp Salt modules are the functions called by the \fBsalt\fP command. @@ -1388,9 +1394,9 @@ regardless of what the actual module is named. .sp The package manager modules are the best example of using the \fB__virtual__\fP function: -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/modules/pacman.py\fP -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/modules/yumpkg.py\fP -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/modules/apt.py\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/modules/pacman.py\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/modules/yumpkg.py\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/modules/apt.py\fP .SS Documentation .sp Salt modules are self documenting, the \fBsys.doc()\fP function will return the @@ -1464,7 +1470,7 @@ functions for salt, but to stand as examples for building out more Salt modules. .sp The existing modules can be found here: -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/modules\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/modules\fP .sp The most simple module is the test module, it contains the simplest salt function, test.ping: @@ -1514,6 +1520,7 @@ _ T{ \fBcluster\fP T} T{ +The cluster module is used to distribute and activate salt HA cluster T} _ T{ @@ -1525,6 +1532,7 @@ _ T{ \fBcp\fP T} T{ +Minion side functions for salt\-cp T} _ T{ @@ -1534,6 +1542,12 @@ Work with cron T} _ T{ +\fBdata\fP +T} T{ +Manage a local persistent data structure that can hold any arbitrairy data +T} +_ +T{ \fBdisk\fP T} T{ Module for gathering disk information @@ -1552,12 +1566,24 @@ Manage information about files on the minion, set/read user, group, and mode T} _ T{ +\fBfreebsdkmod\fP +T} T{ +Module to manage FreeBSD kernel modules +T} +_ +T{ \fBfreebsdpkg\fP T} T{ Package support for FreeBSD T} _ T{ +\fBgentoo_service\fP +T} T{ +Top level package command wrapper, used to translate the os detected by the +T} +_ +T{ \fBgrains\fP T} T{ Control aspects of the grains data @@ -1608,6 +1634,7 @@ _ T{ \fBmysql\fP T} T{ +Module to provide MySQL compatibility to salt. T} _ T{ @@ -1623,13 +1650,21 @@ A module to wrap pacman calls, since Arch is the best T} _ T{ +\fBpip\fP +T} T{ +Install Python packages with pip to either the system or a virtualenv +T} +_ +T{ \fBps\fP T} T{ +A salt interface to psutil, a system and process library. T} _ T{ \fBpublish\fP T} T{ +Publish a command from a minion to a target T} _ T{ @@ -1651,6 +1686,18 @@ Manage users with the useradd command T} _ T{ +\fBrh_service\fP +T} T{ +Top level package command wrapper, used to translate the os detected by the +T} +_ +T{ +\fBsaltutil\fP +T} T{ +The Saltutil module is used to manage the state of the salt minion itself. It is +T} +_ +T{ \fBselinux\fP T} T{ Execute calls on selinux @@ -1683,6 +1730,7 @@ _ T{ \fBstate\fP T} T{ +Control the state system on the minion T} _ T{ @@ -1692,6 +1740,12 @@ Module for returning various status data about a minion. T} _ T{ +\fBsystemd\fP +T} T{ +Provide the service module for systemd +T} +_ +T{ \fBtest\fP T} T{ Module for running arbitrary tests @@ -1716,8 +1770,39 @@ Work with virtual machines managed by libvirt T} _ T{ +\fBvirtualenv\fP +T} T{ +Create virtualenv environments +T} +_ +T{ +\fBwin_disk\fP +T} T{ +Module for gathering disk information on Windows +T} +_ +T{ +\fBwin_service\fP +T} T{ +Windows Service module. +T} +_ +T{ +\fBwin_useradd\fP +T} T{ +Manage Windows users with the net user command +T} +_ +T{ \fByumpkg\fP T} T{ +Support for YUM +T} +_ +T{ +\fByumpkg5\fP +T} T{ +Support for YUM T} _ .TE @@ -2164,6 +2249,16 @@ salt \(aq*\(aq buttervm.local_images .ft P .fi .UNINDENT +.SS salt.modules.cluster +.sp +The cluster module is used to distribute and activate salt HA cluster +components +.INDENT 0.0 +.TP +.B salt.modules.cluster.distrib(minions, master_conf, master_pem, conf_file) +Set up this minion as a failover master \- only intended for use by the +cluster interface +.UNINDENT .SS salt.modules.cmd .sp A module for shelling out @@ -2200,8 +2295,8 @@ salt \(aq*\(aq cmd.has_exec cat .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.retcode(cmd, runas=None, cwd=\(aq/home/thatch\(aq) -Execute a shell command and return the command\(aqs return code +.B salt.modules.cmd.retcode(cmd, cwd=\(aq/home/thatch\(aq, runas=None) +Execute a shell command and return the command\(aqs return code. .sp CLI Example: .sp @@ -2213,7 +2308,7 @@ salt \(aq*\(aq cmd.retcode "file /bin/bash" .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.run(cmd, runas=None, cwd=\(aq/home/thatch\(aq) +.B salt.modules.cmd.run(cmd, cwd=\(aq/home/thatch\(aq, runas=None) Execute the passed command and return the output as a string .sp CLI Example: @@ -2226,7 +2321,7 @@ salt \(aq*\(aq cmd.run "ls \-l | awk \(aq/foo/{print $2}\(aq" .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.run_all(cmd, runas=None, cwd=\(aq/home/thatch\(aq) +.B salt.modules.cmd.run_all(cmd, cwd=\(aq/home/thatch\(aq, runas=None) Execute the passed command and return a dict of return data .sp CLI Example: @@ -2239,7 +2334,7 @@ salt \(aq*\(aq cmd.run_all "ls \-l | awk \(aq/foo/{print $2}\(aq" .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.run_stderr(cmd, runas=None, cwd=\(aq/home/thatch\(aq) +.B salt.modules.cmd.run_stderr(cmd, cwd=\(aq/home/thatch\(aq, runas=None) Execute a command and only return the standard error .sp CLI Example: @@ -2252,7 +2347,7 @@ salt \(aq*\(aq cmd.run_stderr "ls \-l | awk \(aq/foo/{print $2}\(aq" .UNINDENT .INDENT 0.0 .TP -.B salt.modules.cmd.run_stdout(cmd, runas=None, cwd=\(aq/home/thatch\(aq) +.B salt.modules.cmd.run_stdout(cmd, cwd=\(aq/home/thatch\(aq, runas=None) Execute a command, and only return the standard out .sp CLI Example: @@ -2276,6 +2371,85 @@ salt \(aq*\(aq cmd.which cat .ft P .fi .UNINDENT +.SS salt.modules.cp +.sp +Minion side functions for salt\-cp +.INDENT 0.0 +.TP +.B salt.modules.cp.cache_dir(path, env=\(aqbase\(aq) +Download and cache everything under a directory from the master +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.cache_file(path, env=\(aqbase\(aq) +Used to cache a single file in the local salt\-master file cache. +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.cache_files(paths, env=\(aqbase\(aq) +Used to gather many files from the master, the gathered files will be +saved in the minion cachedir reflective to the paths retrieved from the +master. +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.cache_local_file(path) +Cache a local file on the minion in the localfiles cache +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.cache_master(env=\(aqbase\(aq) +Retrieve all of the files on the master and cache them locally +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.get_file(path, dest, env=\(aqbase\(aq) +Used to get a single file from the salt master +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.get_url(path, dest, env=\(aqbase\(aq) +Used to get a single file from a URL. +.sp +For example: +.sp +.nf +.ft C +cp.get_url salt://my/file /tmp/mine +cp.get_url http://www.slashdot.org /tmp/index.html +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.hash_file(path, env=\(aqbase\(aq) +Return the hash of a file, to get the hash of a file on the +salt master file server prepend the path with salt:// +otherwise, prepend the file with / for a local file. +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.is_cached(path, env=\(aqbase\(aq) +Return a boolean if the given path on the master has been cached on the +minion +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.list_master(env=\(aqbase\(aq) +List all of the files stored on the master +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.list_minion(env=\(aqbase\(aq) +List all of the files cached on the minion +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.cp.recv(files, dest) +Used with salt\-cp, pass the files dict, and the destination. +.sp +This function receives small fast copy files from the master via salt\-cp +.UNINDENT .SS salt.modules.cron .sp Work with cron @@ -2338,6 +2512,75 @@ salt \(aq*\(aq cron.set_special @hourly \(aqecho foobar\(aq .ft P .fi .UNINDENT +.SS salt.modules.data +.sp +Manage a local persistent data structure that can hold any arbitrairy data +specific to the minion +.INDENT 0.0 +.TP +.B salt.modules.data.dump(new_data) +Replace the entire datastore with a passed data structure +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq data.dump \(aq{\(aqeggs\(aq: \(aqspam\(aq}\(aq +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.data.getval(key) +Get a value from the minion datastore +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq data.getval +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.data.getvals(keys) +Get values from the minion datastore +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq data.getvals +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.data.load() +Return all of the data in the minion datastore +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq data.load +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.data.update(key, value) +Update a key with a value in the minion datastore +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq data.update +.ft P +.fi +.UNINDENT .SS salt.modules.disk .sp Module for gathering disk information @@ -3007,6 +3250,74 @@ salt \(aq*\(aq file.user_to_uid root .ft P .fi .UNINDENT +.SS salt.modules.freebsdkmod +.sp +Module to manage FreeBSD kernel modules +.INDENT 0.0 +.TP +.B salt.modules.freebsdkmod.available() +Return a list of all available kernel modules +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq kmod.available +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.freebsdkmod.check_available(mod) +Check to see if the specified kernel module is available +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq kmod.check_available kvm +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.freebsdkmod.load(mod) +Load the specified kernel module +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq kmod.load kvm +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.freebsdkmod.lsmod() +Return a dict containing information about currently loaded modules +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq kmod.lsmod +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.freebsdkmod.remove(mod) +Remove the specified kernel module +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq kmod.remove kvm +.ft P +.fi +.UNINDENT .SS salt.modules.freebsdpkg .sp Package support for FreeBSD @@ -3143,122 +3454,271 @@ salt \(aq*\(aq pkg.version .ft P .fi .UNINDENT -.SS salt.modules.grains +.SS salt.modules.gentoo_service .sp -Control aspects of the grains data +Top level package command wrapper, used to translate the os detected by the +grains to the correct service manager .INDENT 0.0 .TP -.B salt.modules.grains.item(key=None) -Return a singe component of the grains data +.B salt.modules.gentoo_service.disable(name) +Disable the named service to start at boot .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq grains.item os +salt \(aq*\(aq service.disable .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.grains.items() -Return the grains data +.B salt.modules.gentoo_service.disabled(name) +Return True if the named servioce is enabled, false otherwise .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq grains.items +salt \(aq*\(aq service.enabled .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.grains.ls() -Return a list of all available grains +.B salt.modules.gentoo_service.enable(name) +Enable the named service to start at boot .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq grains.ls +salt \(aq*\(aq service.enable .ft P .fi .UNINDENT -.SS salt.modules.groupadd -.sp -Manage groups on Linux .INDENT 0.0 .TP -.B salt.modules.groupadd.add(name, gid=None) -Add the specified group +.B salt.modules.gentoo_service.enabled(name) +Return True if the named servioce is enabled, false otherwise .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.add foo 3456 +salt \(aq*\(aq service.enabled .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.groupadd.chgid(name, gid) -Change the gid for a named group +.B salt.modules.gentoo_service.get_all() +Return all available boot services .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.chgid foo 4376 +salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.groupadd.delete(name) -Remove the named group +.B salt.modules.gentoo_service.get_disabled() +Return a set of services that are installed but disabled .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.delete foo +salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.groupadd.getent() -Return info on all groups +.B salt.modules.gentoo_service.get_enabled() +Return a list of service that are enabled on boot .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.getent +salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.groupadd.info(name) -Return information about a group +.B salt.modules.gentoo_service.restart(name) +Restart the named service .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.info foo +salt \(aq*\(aq service.restart .ft P .fi .UNINDENT -.SS salt.modules.hosts +.INDENT 0.0 +.TP +.B salt.modules.gentoo_service.start(name) +Start the specified service .sp -Manage the information in the hosts file +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.start +.ft P +.fi +.UNINDENT .INDENT 0.0 .TP -.B salt.modules.hosts.add_host(ip, alias) +.B salt.modules.gentoo_service.status(name, sig=None) +Return the status for a service, returns the PID or an empty string if the +service is running or not, pass a signature to use to find the service via +ps +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.status [service signature] +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.gentoo_service.stop(name) +Stop the specified service +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.stop +.ft P +.fi +.UNINDENT +.SS salt.modules.grains +.sp +Control aspects of the grains data +.INDENT 0.0 +.TP +.B salt.modules.grains.item(key=None) +Return a singe component of the grains data +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq grains.item os +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.grains.items() +Return the grains data +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq grains.items +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.grains.ls() +Return a list of all available grains +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq grains.ls +.ft P +.fi +.UNINDENT +.SS salt.modules.groupadd +.sp +Manage groups on Linux +.INDENT 0.0 +.TP +.B salt.modules.groupadd.add(name, gid=None) +Add the specified group +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.add foo 3456 +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.groupadd.chgid(name, gid) +Change the gid for a named group +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.chgid foo 4376 +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.groupadd.delete(name) +Remove the named group +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.delete foo +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.groupadd.getent() +Return info on all groups +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.getent +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.groupadd.info(name) +Return information about a group +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.info foo +.ft P +.fi +.UNINDENT +.SS salt.modules.hosts +.sp +Manage the information in the hosts file +.INDENT 0.0 +.TP +.B salt.modules.hosts.add_host(ip, alias) Add a host to an existing entry, if the entry is not in place then create it with the given host .INDENT 7.0 @@ -3636,1816 +4096,3599 @@ salt \(aq*\(aq mount.set_fstab /mnt/foo /dev/sdz1 ext4 .ft P .fi .UNINDENT -.SS salt.modules.network +.SS salt.modules.mysql .sp -Module for gathering and managing network information -.INDENT 0.0 -.TP -.B salt.modules.network.dig(host) -Performs a DNS lookup with dig +Module to provide MySQL compatibility to salt. .sp -CLI Example: +In order to connect to MySQL, certain configuration is required +in /etc/salt/minion on the relevant minions. Some sample configs +might look like: .sp .nf .ft C -salt \(aq*\(aq network.dig archlinux.org +mysql.host: \(aqlocalhost\(aq +mysql.port: 3306 +mysql.user: \(aqroot\(aq +mysql.pass: \(aq\(aq +mysql.db: \(aqmysql\(aq .ft P .fi -.UNINDENT -.INDENT 0.0 -.TP -.B salt.modules.network.isportopen(host, port) -Return status of a port .sp -CLI Example: +You can also use a defaults file: .sp .nf .ft C -salt \(aq*\(aq network.isportopen 127.0.0.1 22 +mysql.default_file: \(aq/etc/mysql/debian.cnf\(aq .ft P .fi +.INDENT 0.0 +.TP +.B salt.modules.mysql.connect(**kwargs) +wrap authentication credentials here .UNINDENT .INDENT 0.0 .TP -.B salt.modules.network.netstat() -Return information on open ports and states +.B salt.modules.mysql.db_check(name, table=None) +Repairs the full database or just a given table .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq network.netstat +salt \(aq*\(aq mysqldb.db_check dbname .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.network.ping(host) -Performs a ping to a host +.B salt.modules.mysql.db_create(name) +Adds a databases to the MySQL server. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq network.ping archlinux.org \-c 4 +salt \(aq*\(aq mysqldb.db_create \(aqdbname\(aq .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.network.traceroute(host) -Performs a traceroute to a 3rd party host +.B salt.modules.mysql.db_exists(name) +Checks if a database exists on the MySQL server. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq network.traceroute archlinux.org +salt \(aq*\(aq mysqldb.db_exists \(aqdbname\(aq .ft P .fi .UNINDENT -.SS salt.modules.pacman -.sp -A module to wrap pacman calls, since Arch is the best -(\fI\%https://wiki.archlinux.org/index.php/Arch_is_the_best\fP) .INDENT 0.0 .TP -.B salt.modules.pacman.available_version(name) -The available version of the package in the repository +.B salt.modules.mysql.db_list() +Return a list of databases of a MySQL server using the output +from the \fBSHOW DATABASES\fP query. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq pkg.available_version +salt \(aq*\(aq mysqldb.db_list .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pacman.install(name, refresh=False, **kwargs) -Install the passed package, add refresh=True to install with an \-Sy +.B salt.modules.mysql.db_optimize(name, table=None) +Optimizes the full database or just a given table .sp -Return a dict containing the new package names and versions: +CLI Example: .sp .nf .ft C -{\(aq\(aq: {\(aqold\(aq: \(aq\(aq, - \(aqnew\(aq: \(aq\(aq]} +salt \(aq*\(aq mysqldb.db_optimize dbname .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.mysql.db_remove(name) +Removes a databases from the MySQL server. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq pkg.install +salt \(aq*\(aq mysqldb.db_remove \(aqdbname\(aq .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pacman.list_pkgs() -List the packages currently installed as a dict: +.B salt.modules.mysql.db_repair(name, table=None) +Repairs the full database or just a given table +.sp +CLI Example: .sp .nf .ft C -{\(aq\(aq: \(aq\(aq} +salt \(aq*\(aq mysqldb.db_repair dbname .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.mysql.db_tables(name) +Shows the tables in the given MySQL database (if exists) .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq pkg.list_pkgs +salt \(aq*\(aq mysqldb.db_tables \(aqdatabase\(aq .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pacman.purge(name) -Recursively remove a package and all dependencies which were installed -with it, this will call a \fBpacman \-Rsc\fP -.sp -Return a list containing the removed packages. +.B salt.modules.mysql.free_slave() +Frees a slave from its master. This is a WIP, do not use. +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.mysql.slave_lag() +Return the number of seconds that a slave SQL server is lagging behind the +master, if the host is not a slave it will return \-1. If the server is +configured to be a slave but replication but slave IO is not running then +\-2 will be returned. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq pkg.purge +salt \(aq*\(aq mysql.slave_lag .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pacman.refresh_db() -Just run a \fBpacman \-Sy\fP, return a dict: +.B salt.modules.mysql.status() +Return the status of a MySQL server using the output +from the \fBSHOW STATUS\fP query. +.sp +CLI Example: .sp .nf .ft C -{\(aq\(aq: Bool} +salt \(aq*\(aq mysql.status .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.mysql.user_chpass(user, host=\(aqlocalhost\(aq, password=None) +Change password for MySQL user .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq pkg.refresh_db +salt \(aq*\(aq mysqldb.user_chpass frank localhost newpassword .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pacman.remove(name) -Remove a single package with \fBpacman \-R\fP -.sp -Return a list containing the removed packages. +.B salt.modules.mysql.user_create(user, host=\(aqlocalhost\(aq, password=None) +Creates a MySQL user. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq pkg.remove +salt \(aq*\(aq mysqldb.user_create \(aqusername\(aq \(aqhostname\(aq \(aqpassword\(aq .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pacman.upgrade() -Run a full system upgrade, a pacman \-Syu +.B salt.modules.mysql.user_exists(user, host=\(aqlocalhost\(aq) +Checks if a user exists on the MySQL server. .sp -Return a dict containing the new package names and versions: +CLI Example: .sp .nf .ft C -{\(aq\(aq: {\(aqold\(aq: \(aq\(aq, - \(aqnew\(aq: \(aq\(aq]} +salt \(aq*\(aq mysqldb.user_exists \(aqusername\(aq \(aqhostname\(aq .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.mysql.user_info(user, host=\(aqlocalhost\(aq) +Get full info on a MySQL user .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq pkg.upgrade +salt \(aq*\(aq mysqldb.user_info root localhost .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pacman.version(name) -Returns a version if the package is installed, else returns an empty string +.B salt.modules.mysql.user_list() +Return a list of users on a MySQL server .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq pkg.version +salt \(aq*\(aq mysqldb.user_list .ft P .fi .UNINDENT -.SS salt.modules.puppet -.sp -Execute puppet routines .INDENT 0.0 .TP -.B salt.modules.puppet.run() -Execute a puppet run and return a dict with the stderr,stdout,return code -etc. +.B salt.modules.mysql.user_remove(user, host=\(aqlocalhost\(aq) +Delete MySQL user .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq puppet.run +salt \(aq*\(aq mysqldb.user_remove frank localhost .ft P .fi .UNINDENT -.SS salt.modules.pw_group -.sp -Manage groups on Linux .INDENT 0.0 .TP -.B salt.modules.pw_group.add(name, gid=None) -Add the specified group +.B salt.modules.mysql.version() +Return the version of a MySQL server using the output +from the \fBSELECT VERSION()\fP query. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.add foo 3456 +salt \(aq*\(aq mysql.version .ft P .fi .UNINDENT +.SS salt.modules.network +.sp +Module for gathering and managing network information .INDENT 0.0 .TP -.B salt.modules.pw_group.chgid(name, gid) -Change the gid for a named group +.B salt.modules.network.dig(host) +Performs a DNS lookup with dig .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.chgid foo 4376 +salt \(aq*\(aq network.dig archlinux.org .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_group.delete(name) -Remove the named group +.B salt.modules.network.hwaddr(interface) +Returns the hwaddr for a given interface .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.delete foo +salt \(aq*\(aq network.hwaddr eth0 .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_group.getent() -Return info on all groups +.B salt.modules.network.ipaddr(interface) +Returns the IP address for a given interface .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.getent +salt \(aq*\(aq network.ipaddr eth0 .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_group.info(name) -Return information about a group +.B salt.modules.network.isportopen(host, port) +Return status of a port .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq group.info foo +salt \(aq*\(aq network.isportopen 127.0.0.1 22 .ft P .fi .UNINDENT -.SS salt.modules.pw_user -.sp -Manage users with the useradd command .INDENT 0.0 .TP -.B salt.modules.pw_user.add(name, uid=None, gid=None, groups=None, home=False, shell=\(aq/bin/false\(aq) -Add a user to the minion +.B salt.modules.network.netmask(interface) +Returns the netmask for a given interface .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.add name +salt \(aq*\(aq network.netmask eth0 .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_user.chgid(name, gid) -Change the default group of the user +.B salt.modules.network.netstat() +Return information on open ports and states .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chgid foo 4376 +salt \(aq*\(aq network.netstat .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_user.chgroups(name, groups, append=False) -Change the groups this user belongs to, add append to append the specified -groups +.B salt.modules.network.ping(host) +Performs a ping to a host .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chgroups foo wheel,root True +salt \(aq*\(aq network.ping archlinux.org \-c 4 .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_user.chhome(name, home, persist=False) -Change the home directory of the user, pass true for persist to copy files -to the new home dir +.B salt.modules.network.traceroute(host) +Performs a traceroute to a 3rd party host .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chhome foo /home/users/foo True +salt \(aq*\(aq network.traceroute archlinux.org .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_user.chshell(name, shell) -Change the default shell of the user +.B salt.modules.network.up(interface) +Returns True if interface is up, otherwise returns False .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chshell foo /bin/zsh +salt \(aq*\(aq network.up eth0 .ft P .fi .UNINDENT +.SS salt.modules.pacman +.sp +A module to wrap pacman calls, since Arch is the best +(\fI\%https://wiki.archlinux.org/index.php/Arch_is_the_best\fP) .INDENT 0.0 .TP -.B salt.modules.pw_user.chuid(name, uid) -Change the uid for a named user +.B salt.modules.pacman.available_version(name) +The available version of the package in the repository .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chuid foo 4376 +salt \(aq*\(aq pkg.available_version .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_user.delete(name, remove=False, force=False) -Remove a user from the minion +.B salt.modules.pacman.install(name, refresh=False, **kwargs) +Install the passed package, add refresh=True to install with an \-Sy +.sp +Return a dict containing the new package names and versions: +.sp +.nf +.ft C +{\(aq\(aq: {\(aqold\(aq: \(aq\(aq, + \(aqnew\(aq: \(aq\(aq]} +.ft P +.fi .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.delete name True True +salt \(aq*\(aq pkg.install .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_user.getent() -Return the list of all info for all users +.B salt.modules.pacman.list_pkgs() +List the packages currently installed as a dict: +.sp +.nf +.ft C +{\(aq\(aq: \(aq\(aq} +.ft P +.fi .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.getent +salt \(aq*\(aq pkg.list_pkgs .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_user.info(name) -Return user information +.B salt.modules.pacman.purge(name) +Recursively remove a package and all dependencies which were installed +with it, this will call a \fBpacman \-Rsc\fP +.sp +Return a list containing the removed packages. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.info root +salt \(aq*\(aq pkg.purge .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.pw_user.list_groups(name) -Return a list of groups the named user belongs to +.B salt.modules.pacman.refresh_db() +Just run a \fBpacman \-Sy\fP, return a dict: +.sp +.nf +.ft C +{\(aq\(aq: Bool} +.ft P +.fi .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.groups foo +salt \(aq*\(aq pkg.refresh_db .ft P .fi .UNINDENT -.SS salt.modules.selinux +.INDENT 0.0 +.TP +.B salt.modules.pacman.remove(name) +Remove a single package with \fBpacman \-R\fP .sp -Execute calls on selinux +Return a list containing the removed packages. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq pkg.remove +.ft P +.fi +.UNINDENT .INDENT 0.0 .TP -.B salt.modules.selinux.getenforce() -Return the mode selinux is running in +.B salt.modules.pacman.upgrade() +Run a full system upgrade, a pacman \-Syu .sp -CLE Example: +Return a dict containing the new package names and versions: .sp .nf .ft C -salt \(aq*\(aq selinux.getenforce +{\(aq\(aq: {\(aqold\(aq: \(aq\(aq, + \(aqnew\(aq: \(aq\(aq]} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq pkg.upgrade .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.selinux.setenforce(mode) -Set the enforcing mode +.B salt.modules.pacman.version(name) +Returns a version if the package is installed, else returns an empty string +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq pkg.version +.ft P +.fi .UNINDENT -.SS salt.modules.service +.SS salt.modules.pip .sp -The default service module, if not otherwise specified salt will fall back -to this basic module +Install Python packages with pip to either the system or a virtualenv .INDENT 0.0 .TP -.B salt.modules.service.restart(name) -Restart the named service +.B salt.modules.pip.freeze(env=\(aq\(aq, pip_bin=\(aq\(aq) +Return a list of installed packages either globally or in the specified +virtualenv +.INDENT 7.0 +.TP +.B env +None +The path to a virtualenv that pip should install to. This option takes +precendence over the \fBpip_bin\fP argument. +.TP +.B pip_bin +\(aqpip\(aq +The name (and optionally path) of the pip command to call. This option +will be ignored if the \fBenv\fP argument is given since it will default +to the pip that is installed in the virtualenv. This option can also be +set in the minion config file as \fBpip.pip_bin\fP. +.UNINDENT +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pip.install(env=\(aq\(aq, requirements=\(aq\(aq, pkgs=\(aq\(aq, pip_bin=\(aq\(aq) +Install packages with pip +.sp +Install packages individually or from a pip requirements file. Install +packages globally or to a virtualenv. +.INDENT 7.0 +.TP +.B env +None +The path to a virtualenv that pip should install to. This option takes +precendence over the \fBpip_bin\fP argument. +.TP +.B requirements +None +The path to a pip requirements file to install from +.TP +.B pkgs +None +A list of space\-separated packages to install +.TP +.B pip_bin +\(aqpip\(aq +The name (and optionally path) of the pip command to call. This option +will be ignored if the \fBenv\fP argument is given since it will default +to the pip that is installed in the virtualenv. This option can also be +set in the minion config file as \fBpip.pip_bin\fP. +.UNINDENT .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq service.restart +salt \(aq*\(aq pip.install /var/www/myvirtualenv.com \e + /path/to/requirements.txt .ft P .fi .UNINDENT +.SS salt.modules.ps +.sp +A salt interface to psutil, a system and process library. +See \fI\%http://code.google.com/p/psutil\fP. .INDENT 0.0 .TP -.B salt.modules.service.start(name) -Start the specified service +.B salt.modules.ps.boot_time() +Return the boot time in number of seconds since the epoch began. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq service.start +salt \(aq*\(aq ps.boot_time .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.service.status(name, sig=None) -Return the status for a service, returns the PID or an empty string if the -service is running or not, pass a signature to use to find the service via -ps +.B salt.modules.ps.cached_physical_memory() +Return the amount cached memory. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq service.status [service signature] +salt \(aq*\(aq ps.cached_physical_memory .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.service.stop(name) -Stop the specified service +.B salt.modules.ps.cpu_percent(interval=0.1, per_cpu=False) +Return the percent of time the CPU is busy. +.INDENT 7.0 +.TP +.B interval +the number of seconds to sample CPU usage over +.TP +.B per_cpu +if True return an array of CPU percent busy for each CPU, otherwise +aggregate all percents into one number +.UNINDENT .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq service.stop +salt \(aq*\(aq ps.cpu_percent .ft P .fi .UNINDENT -.SS salt.modules.shadow +.INDENT 0.0 +.TP +.B salt.modules.ps.cpu_times(per_cpu=False) +Return the percent of time the CPU spends in each state, +e.g. user, system, idle, nice, iowait, irq, softirq. +.INDENT 7.0 +.TP +.B per_cpu +if True return an array of percents for each CPU, otherwise aggregate +all percents into one number +.UNINDENT .sp -Manage the shadow file +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ps.cpu_times +.ft P +.fi +.UNINDENT .INDENT 0.0 .TP -.B salt.modules.shadow.info(name) -Return information for the specified user +.B salt.modules.ps.disk_partition_usage(all=False) +Return a list of disk partitions plus the mount point, filesystem and usage +statistics. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq shadow.info root +salt \(aq*\(aq ps.disk_partition_usage .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.shadow.set_password(name, password) -Set the password for a named user. The password must be a properly defined -hash, the password hash can be generated with this command: -\fBopenssl passwd \-1 \fP +.B salt.modules.ps.disk_partitions(all=False) +Return a list of disk partitions and their device, mount point, and +filesystem type. +.INDENT 7.0 +.TP +.B all +if set to False, only return local, physical partitions (hard disk, +USB, CD/DVD partitions). If True, return all filesystems. +.UNINDENT .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq shadow.set_password root $1$UYCIxa628.9qXjpQCjM4a.. +salt \(aq*\(aq ps.disk_partitions .ft P .fi .UNINDENT -.SS salt.modules.solr -.SS Apache Solr Salt Module +.INDENT 0.0 +.TP +.B salt.modules.ps.disk_usage(path) +Given a path, return a dict listing the total available space as well as +the free space, and used space. .sp -Author: Jed Glazner -Version: 0.2.1 -Modified: 12/09/2011 +CLI Example: .sp -This module uses http requests to talk to the apache solr request handlers -to gather information and report errors. Because of this the minion doesn\(aqt -necessarily need to reside on the actual slave. However if you want to -use the signal function the minion must reside on the physical solr host. +.nf +.ft C +salt \(aq*\(aq ps.disk_usage /home +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.ps.get_pid_list() +Return a list of process ids (PIDs) for all running processes. .sp -This module supports multi\-core and standard setups. Certain methods are -master/slave specific. Make sure you set the solr.type. If you have -questions or want a feature request please ask. -.SS Coming Features in 0.3 +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ps.get_pid_list +.ft P +.fi +.UNINDENT .INDENT 0.0 -.IP 1. 3 -Add command for checking for replication failures on slaves -.IP 2. 3 -Improve match_index_versions since it\(aqs pointless on busy solr masters -.IP 3. 3 -Add additional local fs checks for backups to make sure they succeeded +.TP +.B salt.modules.ps.num_cpus() +Return the number of CPUs. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ps.num_cpus +.ft P +.fi .UNINDENT -.SS Override these in the minion config .INDENT 0.0 .TP -.B solr.cores -A list of core names eg [\(aqcore1\(aq,\(aqcore2\(aq]. -An empty list indicates non\-multicore setup. +.B salt.modules.ps.physical_memory_buffers() +Return the amount of physical memory buffers. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ps.physical_memory_buffers +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.ps.physical_memory_usage() +Return a dict that describes free and available physical memory. +.sp +CLI Examples: +.sp +.nf +.ft C +salt \(aq*\(aq ps.physical_memory_usage +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.ps.top(num_processes=5, interval=3) +Return a list of top CPU consuming processes during the interval. +num_processes = return the top N CPU consuming processes +interval = the number of seconds to sample CPU usage over +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.ps.total_physical_memory() +Return the total number of bytes of physical memory. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ps.total_physical_memory +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.ps.virtual_memory_usage() +Return a dict that describes free and available memory, both physical +and virtual. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq virtual_memory_usage +.ft P +.fi +.UNINDENT +.SS salt.modules.publish +.sp +Publish a command from a minion to a target +.INDENT 0.0 +.TP +.B salt.modules.publish.publish(tgt, fun, arg=None, expr_form=\(aqglob\(aq, returner=\(aq\(aq) +Publish a command from the minion out to other minions, publications need +to be enabled on the Salt master and the minion needs to have permission +to publish the command. The Salt master will also prevent a recursive +publication loop, this means that a minion cannot command another minion +to command another minion as that would create an infinite command loop. +.sp +The arguments sent to the minion publish function are separated with +commas. This means that for a minion executing a command with multiple +args it will look like this: +.sp +.nf +.ft C +salt system.example.com publish.publish \(aq*\(aq user.add \(aqfoo,1020,1020\(aq +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt system.example.com publish.publish \(aq*\(aq cmd.run \(aqls \-la /tmp\(aq +.ft P +.fi +.UNINDENT +.SS salt.modules.puppet +.sp +Execute puppet routines +.INDENT 0.0 +.TP +.B salt.modules.puppet.run() +Execute a puppet run and return a dict with the stderr,stdout,return code +etc. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq puppet.run +.ft P +.fi +.UNINDENT +.SS salt.modules.pw_group +.sp +Manage groups on Linux +.INDENT 0.0 +.TP +.B salt.modules.pw_group.add(name, gid=None) +Add the specified group +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.add foo 3456 +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_group.chgid(name, gid) +Change the gid for a named group +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.chgid foo 4376 +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_group.delete(name) +Remove the named group +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.delete foo +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_group.getent() +Return info on all groups +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.getent +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_group.info(name) +Return information about a group +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq group.info foo +.ft P +.fi +.UNINDENT +.SS salt.modules.pw_user +.sp +Manage users with the useradd command +.INDENT 0.0 +.TP +.B salt.modules.pw_user.add(name, uid=None, gid=None, groups=None, home=False, shell=\(aq/bin/false\(aq) +Add a user to the minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.add name <uid> <gid> <groups> <home> <shell> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.chgid(name, gid) +Change the default group of the user +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.chgid foo 4376 +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.chgroups(name, groups, append=False) +Change the groups this user belongs to, add append to append the specified +groups +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.chgroups foo wheel,root True +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.chhome(name, home, persist=False) +Change the home directory of the user, pass true for persist to copy files +to the new home dir +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.chhome foo /home/users/foo True +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.chshell(name, shell) +Change the default shell of the user +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.chshell foo /bin/zsh +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.chuid(name, uid) +Change the uid for a named user +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.chuid foo 4376 +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.delete(name, remove=False, force=False) +Remove a user from the minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.delete name True True +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.getent() +Return the list of all info for all users +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.getent +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.info(name) +Return user information +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.info root +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.pw_user.list_groups(name) +Return a list of groups the named user belongs to +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.groups foo +.ft P +.fi +.UNINDENT +.SS salt.modules.rh_service +.sp +Top level package command wrapper, used to translate the os detected by the +grains to the correct service manager +.INDENT 0.0 +.TP +.B salt.modules.rh_service.disable(name) +Disable the named service to start at boot +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.disable <service name> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.disabled(name) +Check to see if the named service is disabled to start on boot +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.disabled <service name> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.enable(name) +Enable the named service to start at boot +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.enable <service name> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.enabled(name) +Check to see if the named service is enabled to start on boot +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.enabled <service name> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.get_all() +Return all installed services +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.get_enabled +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.get_disabled() +Return the disabled services +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.get_enabled +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.get_enabled() +Return the enabled services +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.get_enabled +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.restart(name) +Restart the named service +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.restart <service name> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.start(name) +Start the specified service +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.start <service name> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.status(name, sig=None) +Return the status for a service, returns the PID or an empty string if the +service is running or not, pass a signature to use to find the service via +ps +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.status <service name> [service signature] +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.rh_service.stop(name) +Stop the specified service +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.stop <service name> +.ft P +.fi +.UNINDENT +.SS salt.modules.saltutil +.sp +The Saltutil module is used to manage the state of the salt minion itself. It is +used to manage minion modules as well as automate updates to the salt minion +.INDENT 0.0 +.TP +.B salt.modules.saltutil.sync_all(env=\(aqbase\(aq) +Sync down all of the dynamic modules from the file server for a specific +environment +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq saltutil.sync_all +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.saltutil.sync_grains(env=\(aqbase\(aq) +Sync the grains from the _grains directory on the salt master file +server. This function is environment aware, pass the desired environment +to grab the contents of the _grains directory, base is the default +environment. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq saltutil.sync_grains +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.saltutil.sync_modules(env=\(aqbase\(aq) +Sync the modules from the _modules directory on the salt master file +server. This function is environment aware, pass the desired environment +to grab the contents of the _modules directory, base is the default +environment. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq saltutil.sync_modules +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.saltutil.sync_renderers(env=\(aqbase\(aq) +Sync the renderers from the _renderers directory on the salt master file +server. This function is environment aware, pass the desired environment +to grab the contents of the _renderers directory, base is the default +environment. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq saltutil.sync_renderers +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.saltutil.sync_returners(env=\(aqbase\(aq) +Sync the returners from the _returners directory on the salt master file +server. This function is environment aware, pass the desired environment +to grab the contents of the _returners directory, base is the default +environment. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq saltutil.sync_returners +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.saltutil.sync_states(env=\(aqbase\(aq) +Sync the states from the _states directory on the salt master file +server. This function is environment aware, pass the desired environment +to grab the contents of the _states directory, base is the default +environment. +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq saltutil.sync_states +.ft P +.fi +.UNINDENT +.SS salt.modules.selinux +.sp +Execute calls on selinux +.INDENT 0.0 +.TP +.B salt.modules.selinux.getenforce() +Return the mode selinux is running in +.sp +CLE Example: +.sp +.nf +.ft C +salt \(aq*\(aq selinux.getenforce +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.selinux.setenforce(mode) +Set the enforcing mode +.UNINDENT +.SS salt.modules.service +.sp +The default service module, if not otherwise specified salt will fall back +to this basic module +.INDENT 0.0 +.TP +.B salt.modules.service.restart(name) +Restart the named service +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.restart <service name> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.service.start(name) +Start the specified service +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.start <service name> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.service.status(name, sig=None) +Return the status for a service, returns the PID or an empty string if the +service is running or not, pass a signature to use to find the service via +ps +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.status <service name> [service signature] +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.service.stop(name) +Stop the specified service +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq service.stop <service name> +.ft P +.fi +.UNINDENT +.SS salt.modules.shadow +.sp +Manage the shadow file +.INDENT 0.0 +.TP +.B salt.modules.shadow.info(name) +Return information for the specified user +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq shadow.info root +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.shadow.set_password(name, password) +Set the password for a named user. The password must be a properly defined +hash, the password hash can be generated with this command: +\fBopenssl passwd \-1 <plaintext password>\fP +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq shadow.set_password root $1$UYCIxa628.9qXjpQCjM4a.. +.ft P +.fi +.UNINDENT +.SS salt.modules.solr +.SS Apache Solr Salt Module +.sp +Author: Jed Glazner +Version: 0.2.1 +Modified: 12/09/2011 +.sp +This module uses http requests to talk to the apache solr request handlers +to gather information and report errors. Because of this the minion doesn\(aqt +necessarily need to reside on the actual slave. However if you want to +use the signal function the minion must reside on the physical solr host. +.sp +This module supports multi\-core and standard setups. Certain methods are +master/slave specific. Make sure you set the solr.type. If you have +questions or want a feature request please ask. +.SS Coming Features in 0.3 +.INDENT 0.0 +.IP 1. 3 +Add command for checking for replication failures on slaves +.IP 2. 3 +Improve match_index_versions since it\(aqs pointless on busy solr masters +.IP 3. 3 +Add additional local fs checks for backups to make sure they succeeded +.UNINDENT +.SS Override these in the minion config +.INDENT 0.0 +.TP +.B solr.cores +A list of core names eg [\(aqcore1\(aq,\(aqcore2\(aq]. +An empty list indicates non\-multicore setup. .TP .B solr.baseurl The root level url to access solr via http .TP -.B solr.request_timeout -The number of seconds before timing out an http/https/ftp request. If -nothing is specified then the python global timeout setting is used. +.B solr.request_timeout +The number of seconds before timing out an http/https/ftp request. If +nothing is specified then the python global timeout setting is used. +.TP +.B solr.type +Possible values are \(aqmaster\(aq or \(aqslave\(aq +.TP +.B solr.backup_path +The path to store your backups. If you are using cores and you can specify +to append the core name to the path in the backup method. +.TP +.B solr.num_backups +For versions of solr >= 3.5. Indicates the number of backups to keep. This +option is ignored if your version is less. +.TP +.B solr.init_script +The full path to your init script with start/stop options +.TP +.B solr.dih.options +A list of options to pass to the dih. +.UNINDENT +.SS Required Options for DIH +.INDENT 0.0 +.TP +.B clean +False +Clear the index before importing +.TP +.B commit +True +Commit the documents to the index upon completion +.TP +.B optimize +True +Optimize the index after commit is complete +.TP +.B verbose +True +Get verbose output +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.abort_import(handler, host=None, core_name=None, verbose=False) +MASTER ONLY +Aborts an existing import command to the specified handler. +This command can only be run if the minion is is configured with +solr.type=master +.INDENT 7.0 +.TP +.B handler +str +The name of the data import handler. +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core +str (None) +The core the handler belongs to. +.TP +.B verbose +boolean (False) +Run the command with verbose output. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.abort_import dataimport None music {\(aqclean\(aq:True} +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.backup(host=None, core_name=None, append_core_to_path=False) +Tell solr make a backup. This method can be mis\-leading since it uses the +backup api. If an error happens during the backup you are not notified. +The status: \(aqOK\(aq in the response simply means that solr received the +request successfully. +.INDENT 7.0 +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.TP +.B append_core_to_path +boolean (False) +If True add the name of the core to the backup path. Assumes that +minion backup path is not None. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.backup music +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.core_status(host=None, core_name=None) +MULTI\-CORE HOSTS ONLY +Get the status for a given core or all cores if no core is specified +.INDENT 7.0 +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str +The name of the core to reload +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.core_status None music +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.delta_import(handler, host=None, core_name=None, options={}, extra=[]) +Submits an import command to the specified handler using specified options. +This command can only be run if the minion is is configured with +solr.type=master +.INDENT 7.0 +.TP +.B handler +str +The name of the data import handler. +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core +str (None) +The core the handler belongs to. +.TP +.B options +dict (__opts__) +A list of options such as clean, optimize commit, verbose, and +pause_replication. leave blank to use __opts__ defaults. options will +be merged with __opts__ +.TP +.B extra +dict ([]) +Extra name value pairs to pass to the handler. eg ["name=value"] +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.delta_import dataimport None music {\(aqclean\(aq:True} +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.full_import(handler, host=None, core_name=None, options={}, extra=[]) +MASTER ONLY +Submits an import command to the specified handler using specified options. +This command can only be run if the minion is is configured with +solr.type=master +.INDENT 7.0 +.TP +.B handler +str +The name of the data import handler. +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core +str (None) +The core the handler belongs to. +.TP +.B options +dict (__opts__) +A list of options such as clean, optimize commit, verbose, and +pause_replication. leave blank to use __opts__ defaults. options will +be merged with __opts__ +.TP +.B extra +dict ([]) +Extra name value pairs to pass to the handler. e.g. ["name=value"] +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.full_import dataimport None music {\(aqclean\(aq:True} +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.import_status(handler, host=None, core_name=None, verbose=False) +Submits an import command to the specified handler using specified options. +This command can only be run if the minion is is configured with +solr.type: \(aqmaster\(aq +.INDENT 7.0 +.TP +.B handler +str +The name of the data import handler. +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core +str (None) +The core the handler belongs to. +.TP +.B verbose +boolean (False) +Specifies verbose output +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.import_status dataimport None music False +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.is_replication_enabled(host=None, core_name=None) +SLAVE CALL +Check for errors, and determine if a slave is replicating or not. +.INDENT 7.0 +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.is_replication_enabled music +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.lucene_version(core_name=None) +Gets the lucene version that solr is using. If you are running a multi\-core +setup you should specify a core name since all the cores run under the same +servlet container, they will all have the same version. +.INDENT 7.0 +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.UNINDENT +.sp +Return: dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.lucene_version +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.match_index_versions(host=None, core_name=None) +SLAVE CALL +Verifies that the master and the slave versions are in sync by +comparing the index version. If you are constantly pushing updates +the index the master and slave versions will seldom match. A solution +to this is pause indexing every so often to allow the slave to replicate +and then call this method before allowing indexing to resume. +.INDENT 7.0 +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.match_index_versions music +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.optimize(host=None, core_name=None) +Search queries fast, but it is a very expensive operation. The ideal +process is to run this with a master/slave configuration. Then you +can optimize the master, and push the optimized index to the slaves. +If you are running a single solr instance, or if you are going to run +this on a slave be aware than search performance will be horrible +while this command is being run. Additionally it can take a LONG time +to run and your http request may timeout. If that happens adjust your +timeout settings. +.INDENT 7.0 +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.optimize music +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.ping(host=None, core_name=None) +Does a health check on solr, makes sure solr can talk to the indexes. +.INDENT 7.0 +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.ping music +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.reload_core(host=None, core_name=None) +MULTI\-CORE HOSTS ONLY +Load a new core from the same configuration as an existing registered core. +While the "new" core is initializing, the "old" one will continue to accept +requests. Once it has finished, all new request will go to the "new" core, +and the "old" core will be unloaded. +.INDENT 7.0 +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str +The name of the core to reload +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.reload_core None music + +{\(aqsuccess\(aq:bool, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.reload_import_config(handler, host=None, core_name=None, verbose=False) +MASTER ONLY +re\-loads the handler config XML file. +This command can only be run if the minion is a \(aqmaster\(aq type +.INDENT 7.0 +.TP +.B handler +str +The name of the data import handler. +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core +str (None) +The core the handler belongs to. +.TP +.B verbose +boolean (False) +Run the command with verbose output. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.reload_import_config dataimport None music {\(aqclean\(aq:True} +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.replication_details(host=None, core_name=None) +Get the full replication details. +.INDENT 7.0 +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.replication_details music +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.set_is_polling(polling, host=None, core_name=None) +SLAVE CALL +Prevent the slaves from polling the master for updates. +.INDENT 7.0 +.TP +.B polling +boolean +True will enable polling. False will disable it. +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.set_is_polling False +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.set_replication_enabled(status, host=None, core_name=None) +MASTER ONLY +Sets the master to ignore poll requests from the slaves. Useful when you +don\(aqt want the slaves replicating during indexing or when clearing the +index. +.INDENT 7.0 +.TP +.B status +boolean +Sets the replication status to the specified state. +.TP +.B host +str (None) +The solr host to query. __opts__[\(aqhost\(aq] is default. +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to set the status on all cores. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.set_replication_enabled false, None, music +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.signal(signal=None) +Signals Apache Solr to start, stop, or restart. Obviously this is only +going to work if the minion resides on the solr host. Additionally Solr +doesn\(aqt ship with an init script so one must be created. +.INDENT 7.0 +.TP +.B signal +str (None) +The command to pass to the apache solr init valid values are \(aqstart\(aq, +\(aqstop\(aq, and \(aqrestart\(aq +.UNINDENT +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq solr.signal restart +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.solr.version(core_name=None) +Gets the solr version for the core specified. You should specify a core +here as all the cores will run under the same servlet container and so will +all have the same version. +.INDENT 7.0 +.TP +.B core_name +str (None) +The name of the solr core if using cores. Leave this blank if you are +not using cores or if you want to check all cores. +.UNINDENT +.sp +Return : dict<str,obj>: +.sp +.nf +.ft C +{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +alt \(aq*\(aq solr.version +.ft P +.fi +.UNINDENT +.SS salt.modules.ssh +.sp +Manage client ssh components +.INDENT 0.0 +.TP +.B salt.modules.ssh.auth_keys(user, config=\(aq.ssh/authorized_keys\(aq) +Return the authorized keys for the specified user +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ssh.auth_keys root +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.ssh.host_keys(keydir=None) +Return the minion\(aqs host keys +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ssh.host_keys +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.ssh.rm_auth_key(user, key, config=\(aq.ssh/authorized_keys\(aq) +Remove an authorized key from the specified user\(aqs authorized key file +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ssh.rm_auth_key <user> <key> +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.ssh.set_auth_key(user, key, enc=\(aqssh\-rsa\(aq, comment=\(aq\(aq, options=[], config=\(aq.ssh/authorized_keys\(aq) +Add a key to the authorized_keys file +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq ssh.set_auth_key <user> <key> dsa \(aq[]\(aq .ssh/authorized_keys +.ft P +.fi +.UNINDENT +.SS salt.modules.state +.sp +Control the state system on the minion +.INDENT 0.0 +.TP +.B salt.modules.state.high(data) +Execute the compound calls stored in a single set of high data +This function is mostly intended for testing the state system +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq state.high \(aq{"vim": {"pkg": ["installed"]}}\(aq +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.state.highstate() +Retrive the state data from the salt master for this minion and execute it +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq state.highstate +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.state.low(data) +Execute a single low data call +This function is mostly intended for testing the state system +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq state.low \(aq{"state": "pkg", "fun": "installed", "name": "vi"}\(aq +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.state.show_highstate() +Retrieve the highstate data from the salt master and display it +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq state.show_highstate +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.state.show_lowstate() +List out the low data that will be applied to this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq show_lowstate +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B solr.type -Possible values are \(aqmaster\(aq or \(aqslave\(aq +.B salt.modules.state.sls(mods, env=\(aqbase\(aq) +Execute a set list of state modules from an environment, default +environment is base +.sp +CLI Example: +.INDENT 7.0 +.INDENT 3.5 +salt \(aq*\(aq state.sls core,edit.vim dev +.UNINDENT +.UNINDENT +.UNINDENT +.INDENT 0.0 .TP -.B solr.backup_path -The path to store your backups. If you are using cores and you can specify -to append the core name to the path in the backup method. +.B salt.modules.state.template(tem) +Execute the information stored in a template file on the minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq state.template \(aq<Path to template on the minion>\(aq +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B solr.num_backups -For versions of solr >= 3.5. Indicates the number of backups to keep. This -option is ignored if your version is less. +.B salt.modules.state.template_str(tem) +Execute the information stored in a template file on the minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq state.template_str \(aq<Template String>\(aq +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B solr.init_script -The full path to your init script with start/stop options +.B salt.modules.state.top(topfn) +Execute a specific top file instead of the default +.UNINDENT +.SS salt.modules.status +.sp +Module for returning various status data about a minion. +These data can be useful for compiling into stats later. +.INDENT 0.0 .TP -.B solr.dih.options -A list of options to pass to the dih. +.B salt.modules.status.all_status() +Return a composite of all status data and info for this minion. +Warning: There is a LOT here! +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.all_status +.ft P +.fi .UNINDENT -.SS Required Options for DIH .INDENT 0.0 .TP -.B clean -False -Clear the index before importing +.B salt.modules.status.cpuinfo() +Return the CPU info for this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.cpuinfo +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B commit -True -Commit the documents to the index upon completion +.B salt.modules.status.cpustats() +Return the CPU stats for this minon +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.cpustats +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B optimize -True -Optimize the index after commit is complete +.B salt.modules.status.custom() +Return a custom composite of status data and info for this minon, +based on the minion config file. An example config like might be: +.sp +.nf +.ft C +status.cpustats.custom: [ \(aqcpu\(aq, \(aqctxt\(aq, \(aqbtime\(aq, \(aqprocesses\(aq ] +.ft P +.fi +.sp +Where status refers to status.py, cpustats is the function +where we get our data, and custom is this function It is followed +by a list of keys that we want returned. +.sp +This function is meant to replace all_status(), which returns +anything and everything, which we probably don\(aqt want. +.sp +By default, nothing is returned. Warning: Depending on what you +include, there can be a LOT here! +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.custom +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B verbose -True -Get verbose output +.B salt.modules.status.diskstats() +Return the disk stats for this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.diskstats +.ft P +.fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.abort_import(handler, host=None, core_name=None, verbose=False) -MASTER ONLY -Aborts an existing import command to the specified handler. -This command can only be run if the minion is is configured with -solr.type=master -.INDENT 7.0 +.B salt.modules.status.diskusage(*args) +Return the disk usage for this minion +.sp +Usage: +.sp +.nf +.ft C +salt \(aq*\(aq status.diskusage [paths and/or filesystem types] +.ft P +.fi +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.diskusage # usage for all filesystems +salt \(aq*\(aq status.diskusage / /tmp # usage for / and /tmp +salt \(aq*\(aq status.diskusage ext? # usage for ext[234] filesystems +salt \(aq*\(aq status.diskusage / ext? # usage for / and all ext filesystems +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B handler -str -The name of the data import handler. +.B salt.modules.status.loadavg() +Return the load averages for this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.loadavg +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. +.B salt.modules.status.meminfo() +Return the CPU stats for this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.meminfo +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B core -str (None) -The core the handler belongs to. +.B salt.modules.status.netdev() +Return the network device stats for this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.netdev +.ft P +.fi +.UNINDENT +.INDENT 0.0 .TP -.B verbose -boolean (False) -Run the command with verbose output. +.B salt.modules.status.netstats() +Return the network stats for this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.netstats +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.status.uptime() +Return the uptime for this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.uptime +.ft P +.fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.status.vmstats() +Return the virtual memory stats for this minion +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq status.vmstats +.ft P +.fi .UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.status.w() +Return a list of logged in users for this minion, using the w command .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq status.w .ft P .fi +.UNINDENT +.SS salt.modules.systemd +.sp +Provide the service module for systemd +.INDENT 0.0 +.TP +.B salt.modules.systemd.disable(name) +Disable the named service to not start when the system boots .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.abort_import dataimport None music {\(aqclean\(aq:True} +salt \(aq*\(aq service.disable <service name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.backup(host=None, core_name=None, append_core_to_path=False) -Tell solr make a backup. This method can be mis\-leading since it uses the -backup api. If an error happens during the backup you are not notified. -The status: \(aqOK\(aq in the response simply means that solr received the -request successfully. -.INDENT 7.0 -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. -.TP -.B append_core_to_path -boolean (False) -If True add the name of the core to the backup path. Assumes that -minion backup path is not None. -.UNINDENT +.B salt.modules.systemd.disabled(name) +Return if the named service is disabled to start on boot .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq service.disabled <service name> .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.systemd.enable(name) +Enable the named service to start when the system boots .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.backup music +salt \(aq*\(aq service.enable <service name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.core_status(host=None, core_name=None) -MULTI\-CORE HOSTS ONLY -Get the status for a given core or all cores if no core is specified -.INDENT 7.0 -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str -The name of the core to reload -.UNINDENT +.B salt.modules.systemd.enabled(name) +Return if the named service is enabled to start on boot .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq service.enabled <service name> .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.systemd.get_all() +Return a list of all available services .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.core_status None music +salt \(aq*\(aq service.get_all .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.delta_import(handler, host=None, core_name=None, options={}, extra=[]) -Submits an import command to the specified handler using specified options. -This command can only be run if the minion is is configured with -solr.type=master -.INDENT 7.0 -.TP -.B handler -str -The name of the data import handler. -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core -str (None) -The core the handler belongs to. -.TP -.B options -dict (__opts__) -A list of options such as clean, optimize commit, verbose, and -pause_replication. leave blank to use __opts__ defaults. options will -be merged with __opts__ -.TP -.B extra -dict ([]) -Extra name value pairs to pass to the handler. eg ["name=value"] -.UNINDENT +.B salt.modules.systemd.get_disabled() +Return a list of all disabled services .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq service.get_disabled .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.systemd.get_enabled() +Return a list of all enabled services .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.delta_import dataimport None music {\(aqclean\(aq:True} +salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.full_import(handler, host=None, core_name=None, options={}, extra=[]) -MASTER ONLY -Submits an import command to the specified handler using specified options. -This command can only be run if the minion is is configured with -solr.type=master -.INDENT 7.0 -.TP -.B handler -str -The name of the data import handler. -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core -str (None) -The core the handler belongs to. -.TP -.B options -dict (__opts__) -A list of options such as clean, optimize commit, verbose, and -pause_replication. leave blank to use __opts__ defaults. options will -be merged with __opts__ -.TP -.B extra -dict ([]) -Extra name value pairs to pass to the handler. e.g. ["name=value"] -.UNINDENT +.B salt.modules.systemd.restart(name) +Start the specified service with systemd .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq service.start <service name> .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.systemd.start(name) +Start the specified service with systemd .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.full_import dataimport None music {\(aqclean\(aq:True} +salt \(aq*\(aq service.start <service name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.import_status(handler, host=None, core_name=None, verbose=False) -Submits an import command to the specified handler using specified options. -This command can only be run if the minion is is configured with -solr.type: \(aqmaster\(aq -.INDENT 7.0 -.TP -.B handler -str -The name of the data import handler. -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core -str (None) -The core the handler belongs to. -.TP -.B verbose -boolean (False) -Specifies verbose output -.UNINDENT +.B salt.modules.systemd.status(name, sig=None) +Return the status for a service via systemd, returns the PID if the service +is running or an empty string if the service is not running .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq service.status <service name> .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.systemd.stop(name) +Stop the specifed service with systemd .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.import_status dataimport None music False +salt \(aq*\(aq service.stop <service name> .ft P .fi .UNINDENT +.SS salt.modules.test +.sp +Module for running arbitrary tests .INDENT 0.0 .TP -.B salt.modules.solr.is_replication_enabled(host=None, core_name=None) -SLAVE CALL -Check for errors, and determine if a slave is replicating or not. -.INDENT 7.0 -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. -.UNINDENT +.B salt.modules.test.collatz(start) +Execute the collatz conjecture from the passed starting number, returns +the sequence and the time it took to compute. Used for performance tests. .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq test.collatz 3 .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.test.conf_test() +Return the value for test.foo in the minion configuration file, or return +the default value .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.is_replication_enabled music +salt \(aq*\(aq test.conf_test .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.lucene_version(core_name=None) -Gets the lucene version that solr is using. If you are running a multi\-core -setup you should specify a core name since all the cores run under the same -servlet container, they will all have the same version. -.INDENT 7.0 -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. -.UNINDENT +.B salt.modules.test.cross_test(func, args=[]) +Execute a minion function via the __salt__ object in the test module, used +to verify that the minion functions can be called via the __salt__module .sp -Return: dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq test.cross_test file.gid_to_group 0 .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.test.echo(text) +Return a string \- used for testing the connection .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.lucene_version +salt \(aq*\(aq test.echo \(aqfoo bar baz quo qux\(aq .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.match_index_versions(host=None, core_name=None) -SLAVE CALL -Verifies that the master and the slave versions are in sync by -comparing the index version. If you are constantly pushing updates -the index the master and slave versions will seldom match. A solution -to this is pause indexing every so often to allow the slave to replicate -and then call this method before allowing indexing to resume. -.INDENT 7.0 -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. +.B salt.modules.test.fib(num) +Return a Fibonacci sequence up to the passed number, and the time it took +to compute in seconds. Used for performance tests +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq test.fib 3 +.ft P +.fi .UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.test.get_opts() +Return the configuration options passed to this minion .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq test.get_opts .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.test.outputter(data) +Test the outputter, pass in data to return .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.match_index_versions music +salt \(aq*\(aq test.outputter foobar .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.optimize(host=None, core_name=None) -Search queries fast, but it is a very expensive operation. The ideal -process is to run this with a master/slave configuration. Then you -can optimize the master, and push the optimized index to the slaves. -If you are running a single solr instance, or if you are going to run -this on a slave be aware than search performance will be horrible -while this command is being run. Additionally it can take a LONG time -to run and your http request may timeout. If that happens adjust your -timeout settings. -.INDENT 7.0 -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. -.UNINDENT +.B salt.modules.test.ping() +Just used to make sure the minion is up and responding +Return True .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq test.ping .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.test.version() +Return the version of salt on the minion .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.optimize music +salt \(aq*\(aq test.version .ft P .fi .UNINDENT +.SS salt.modules.tomcat +.sp +Support for Tomcat .INDENT 0.0 .TP -.B salt.modules.solr.ping(host=None, core_name=None) -Does a health check on solr, makes sure solr can talk to the indexes. -.INDENT 7.0 -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. -.UNINDENT +.B salt.modules.tomcat.fullversion() +Return all server information from catalina.sh version .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq tomcat.fullversion .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.tomcat.signal(signal=None) +Signals catalina to start, stop, securestart, forcestop. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.ping music +salt \(aq*\(aq tomcat.signal start .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.reload_core(host=None, core_name=None) -MULTI\-CORE HOSTS ONLY -Load a new core from the same configuration as an existing registered core. -While the "new" core is initializing, the "old" one will continue to accept -requests. Once it has finished, all new request will go to the "new" core, -and the "old" core will be unloaded. -.INDENT 7.0 -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str -The name of the core to reload -.UNINDENT +.B salt.modules.tomcat.version() +Return server version from catalina.sh version .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq tomcat.version .ft P .fi +.UNINDENT +.SS salt.modules.useradd +.sp +Manage users with the useradd command +.INDENT 0.0 +.TP +.B salt.modules.useradd.add(name, uid=None, gid=None, groups=None, home=False, shell=\(aq/bin/false\(aq) +Add a user to the minion .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.reload_core None music - -{\(aqsuccess\(aq:bool, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq user.add name <uid> <gid> <groups> <home> <shell> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.reload_import_config(handler, host=None, core_name=None, verbose=False) -MASTER ONLY -re\-loads the handler config XML file. -This command can only be run if the minion is a \(aqmaster\(aq type -.INDENT 7.0 -.TP -.B handler -str -The name of the data import handler. -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core -str (None) -The core the handler belongs to. -.TP -.B verbose -boolean (False) -Run the command with verbose output. -.UNINDENT +.B salt.modules.useradd.chgid(name, gid) +Change the default group of the user .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq user.chgid foo 4376 .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.useradd.chgroups(name, groups, append=False) +Change the groups this user belongs to, add append to append the specified +groups .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.reload_import_config dataimport None music {\(aqclean\(aq:True} +salt \(aq*\(aq user.chgroups foo wheel,root True .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.replication_details(host=None, core_name=None) -Get the full replication details. -.INDENT 7.0 -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. -.UNINDENT +.B salt.modules.useradd.chhome(name, home, persist=False) +Change the home directory of the user, pass true for persist to copy files +to the new home dir .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq user.chhome foo /home/users/foo True .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.useradd.chshell(name, shell) +Change the default shell of the user .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.replication_details music +salt \(aq*\(aq user.chshell foo /bin/zsh .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.set_is_polling(polling, host=None, core_name=None) -SLAVE CALL -Prevent the slaves from polling the master for updates. -.INDENT 7.0 -.TP -.B polling -boolean -True will enable polling. False will disable it. -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. -.UNINDENT +.B salt.modules.useradd.chuid(name, uid) +Change the uid for a named user .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq user.chuid foo 4376 .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.useradd.delete(name, remove=False, force=False) +Remove a user from the minion .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.set_is_polling False +salt \(aq*\(aq user.delete name True True .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.set_replication_enabled(status, host=None, core_name=None) -MASTER ONLY -Sets the master to ignore poll requests from the slaves. Useful when you -don\(aqt want the slaves replicating during indexing or when clearing the -index. -.INDENT 7.0 -.TP -.B status -boolean -Sets the replication status to the specified state. -.TP -.B host -str (None) -The solr host to query. __opts__[\(aqhost\(aq] is default. -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to set the status on all cores. -.UNINDENT +.B salt.modules.useradd.getent() +Return the list of all info for all users .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq user.getent .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.useradd.info(name) +Return user information .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.set_replication_enabled false, None, music +salt \(aq*\(aq user.info root .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.signal(signal=None) -Signals Apache Solr to start, stop, or restart. Obviously this is only -going to work if the minion resides on the solr host. Additionally Solr -doesn\(aqt ship with an init script so one must be created. -.INDENT 7.0 -.TP -.B signal -str (None) -The command to pass to the apache solr init valid values are \(aqstart\(aq, -\(aqstop\(aq, and \(aqrestart\(aq +.B salt.modules.useradd.list_groups(name) +Return a list of groups the named user belongs to +.sp +CLI Example: +.sp +.nf +.ft C +salt \(aq*\(aq user.groups foo +.ft P +.fi .UNINDENT +.SS salt.modules.virt +.sp +Work with virtual machines managed by libvirt +.INDENT 0.0 +.TP +.B salt.modules.virt.create(vm_) +Start a defined domain .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq solr.signal restart +salt \(aq*\(aq virt.create <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.solr.version(core_name=None) -Gets the solr version for the core specified. You should specify a core -here as all the cores will run under the same servlet container and so will -all have the same version. -.INDENT 7.0 -.TP -.B core_name -str (None) -The name of the solr core if using cores. Leave this blank if you are -not using cores or if you want to check all cores. -.UNINDENT +.B salt.modules.virt.create_xml_path(path) +Start a defined domain .sp -Return : dict<str,obj>: +CLI Example: .sp .nf .ft C -{\(aqsuccess\(aq:boolean, \(aqdata\(aq:dict, \(aqerrors\(aq:list, \(aqwarnings\(aq:list} +salt \(aq*\(aq virt.create_xml_path <path to xml file on the node> .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.virt.create_xml_str(xml) +Start a domain based on the xml passed to the function .sp CLI Example: .sp .nf .ft C -alt \(aq*\(aq solr.version +salt \(aq*\(aq virt.create_xml_str <xml in string format> .ft P .fi .UNINDENT -.SS salt.modules.ssh -.sp -Manage client ssh components .INDENT 0.0 .TP -.B salt.modules.ssh.auth_keys(user, config=\(aq.ssh/authorized_keys\(aq) -Return the authorized keys for the specified user +.B salt.modules.virt.destroy(vm_) +Hard power down the virtual machine, this is equivalent to pulling the +power .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq ssh.auth_keys root +salt \(aq*\(aq virt.destroy <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.ssh.host_keys(keydir=None) -Return the minion\(aqs host keys +.B salt.modules.virt.freecpu() +Return an int representing the number of unallocated cpus on this +hypervisor .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq ssh.host_keys +salt \(aq*\(aq virt.freemem .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.ssh.rm_auth_key(user, key, config=\(aq.ssh/authorized_keys\(aq) -Remove an authorized key from the specified user\(aqs authorized key file +.B salt.modules.virt.freemem() +Return an int representing the amount of memory that has not been given +to virtual machines on this node .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq ssh.rm_auth_key <user> <key> +salt \(aq*\(aq virt.freemem .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.ssh.set_auth_key(user, key, enc=\(aqssh\-rsa\(aq, comment=\(aq\(aq, options=[], config=\(aq.ssh/authorized_keys\(aq) -Add a key to the authorized_keys file +.B salt.modules.virt.full_info() +Return the node_info, vm_info and freemem .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq ssh.set_auth_key <user> <key> dsa \(aq[]\(aq .ssh/authorized_keys +salt \(aq*\(aq virt.full_info .ft P .fi .UNINDENT -.SS salt.modules.status -.sp -Module for returning various status data about a minion. -These data can be useful for compiling into stats later. .INDENT 0.0 .TP -.B salt.modules.status.all_status() -Return a composite of all status data and info for this minion. -Warning: There is a LOT here! +.B salt.modules.virt.get_disks(vm_) +Return the disks of a named vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.all_status +salt \(aq*\(aq virt.get_disks <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.cpuinfo() -Return the CPU info for this minion +.B salt.modules.virt.get_graphics(vm_) +Returns the information on vnc for a given vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.cpuinfo +salt \(aq*\(aq virt.get_graphics <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.cpustats() -Return the CPU stats for this minon +.B salt.modules.virt.get_xml(vm_) +Returns the xml for a given vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.cpustats +salt \(aq*\(aq virt.get_xml <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.custom() -Return a custom composite of status data and info for this minon, -based on the minion config file. An example config like might be: +.B salt.modules.virt.is_kvm_hyper() +Returns a bool whether or not this node is a hypervisor +.sp +CLI Example: .sp .nf .ft C -status.cpustats.custom: [ \(aqcpu\(aq, \(aqctxt\(aq, \(aqbtime\(aq, \(aqprocesses\(aq ] +salt \(aq*\(aq virt.is_kvm_hyper .ft P .fi -.sp -Where status refers to status.py, cpustats is the function -where we get our data, and custom is this function It is followed -by a list of keys that we want returned. -.sp -This function is meant to replace all_status(), which returns -anything and everything, which we probably don\(aqt want. -.sp -By default, nothing is returned. Warning: Depending on what you -include, there can be a LOT here! +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.virt.list_vms() +Return a list of virtual machine names on the minion .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.custom +salt \(aq*\(aq virt.list_vms .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.diskstats() -Return the disk stats for this minion +.B salt.modules.virt.migrate(vm_, target) +Shared storage migration .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.diskstats +salt \(aq*\(aq virt.migrate <vm name> <target hypervisor> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.diskusage(*args) -Return the disk usage for this minion +.B salt.modules.virt.migrate_non_shared(vm_, target) +Attempt to execute non\-shared storage "all" migration .sp -Usage: +CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.diskusage [paths and/or filesystem types] +salt \(aq*\(aq virt.migrate_non_shared <vm name> <target hypervisor> .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.virt.migrate_non_shared_inc(vm_, target) +Attempt to execute non\-shared storage "all" migration .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.diskusage # usage for all filesystems -salt \(aq*\(aq status.diskusage / /tmp # usage for / and /tmp -salt \(aq*\(aq status.diskusage ext? # usage for ext[234] filesystems -salt \(aq*\(aq status.diskusage / ext? # usage for / and all ext filesystems +salt \(aq*\(aq virt.migrate_non_shared_inc <vm name> <target hypervisor> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.loadavg() -Return the load averages for this minion +.B salt.modules.virt.node_info() +Return a dict with information about this node .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.loadavg +salt \(aq*\(aq virt.node_info .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.meminfo() -Return the CPU stats for this minion +.B salt.modules.virt.pause(vm_) +Pause the named vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.meminfo +salt \(aq*\(aq virt.pause <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.netdev() -Return the network device stats for this minion +.B salt.modules.virt.purge(vm_, dirs=False) +Recursively destroy and delete a virtual machine, pass True for dir\(aqs to +also delete the directories containing the virtual machine disk images \- +USE WITH EXTREME CAUTION! .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.netdev +salt \(aq*\(aq virt.purge <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.netstats() -Return the network stats for this minion +.B salt.modules.virt.resume(vm_) +Resume the named vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.netstats +salt \(aq*\(aq virt.resume <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.uptime() -Return the uptime for this minion +.B salt.modules.virt.seed_non_shared_migrate(disks, force=False) +Non shared migration requires that the disks be present on the migration +destination, pass the disks information via this function, to the +migration destination before executing the migration. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.uptime +salt \(aq*\(aq virt.seed_non_shared_migrate <disks> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.vmstats() -Return the virtual memory stats for this minion +.B salt.modules.virt.set_autostart(vm_, state=\(aqon\(aq) +Set the autostart flag on a VM so that the VM will start with the host +system on reboot. +.INDENT 7.0 +.TP +.B CLI Example:: +salt "*" virt.enable_autostart <vm name> <on | off> +.UNINDENT +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.virt.shutdown(vm_) +Send a soft shutdown signal to the named vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.vmstats +salt \(aq*\(aq virt.shutdown <vm name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.status.w() -Return a list of logged in users for this minion, using the w command +.B salt.modules.virt.undefine(vm_) +Remove a defined vm, this does not purge the virtual machine image, and +this only works if the vm is powered down .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq status.w +salt \(aq*\(aq virt.undefine <vm name> .ft P .fi .UNINDENT -.SS salt.modules.test -.sp -Module for running arbitrary tests .INDENT 0.0 .TP -.B salt.modules.test.collatz(start) -Execute the collatz conjecture from the passed starting number, returns -the sequence and the time it took to compute. Used for performance tests. +.B salt.modules.virt.virt_type() +Returns the virtual machine type as a string .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.collatz 3 +salt \(aq*\(aq virt.virt_type .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.test.conf_test() -Return the value for test.foo in the minion configuration file, or return -the default value +.B salt.modules.virt.vm_info() +Return detailed information about the vms on this hyper in a dict: +.sp +.nf +.ft C +{\(aqcpu\(aq: <int>, +\(aqmaxMem\(aq: <int>, +\(aqmem\(aq: <int>, +\(aqstate\(aq: \(aq<state>\(aq, +\(aqcputime\(aq <int>} +.ft P +.fi .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.conf_test +salt \(aq*\(aq virt.vm_info .ft P .fi .UNINDENT +.SS salt.modules.virtualenv +.sp +Create virtualenv environments .INDENT 0.0 .TP -.B salt.modules.test.cross_test(func, args=[]) -Execute a minion function via the __salt__ object in the test module, used -to verify that the minion functions can be called via the __salt__module +.B salt.modules.virtualenv.create(path, venv_bin=\(aq\(aq, no_site_packages=False, system_site_packages=False, clear=False, python=\(aq\(aq, extra_search_dir=\(aq\(aq, never_download=False, prompt=\(aq\(aq) +Create a virtualenv +.INDENT 7.0 +.TP +.B path +The path to create the virtualenv +.TP +.B venv_bin +\(aqvirtualenv\(aq +The name (and optionally path) of the virtualenv command. This can also +be set globally in the minion config file as \fBvirtualenv.venv_bin\fP. +.TP +.B no_site_packages +False +Passthrough argument given to virtualenv +.TP +.B system_site_packages +False +Passthrough argument given to virtualenv +.TP +.B clear +False +Passthrough argument given to virtualenv +.TP +.B python +(default) +Passthrough argument given to virtualenv +.TP +.B extra_search_dir +(default) +Passthrough argument given to virtualenv +.TP +.B never_download +(default) +Passthrough argument given to virtualenv +.TP +.B prompt +(default) +Passthrough argument given to virtualenv +.UNINDENT .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.cross_test file.gid_to_group 0 +salt \(aq*\(aq pip.virtualenv /path/to/new/virtualenv .ft P .fi .UNINDENT +.SS salt.modules.win_disk +.sp +Module for gathering disk information on Windows .INDENT 0.0 .TP -.B salt.modules.test.echo(text) -Return a string \- used for testing the connection +.B salt.modules.win_disk.usage() +Return usage information for volumes mounted on this minion .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.echo \(aqfoo bar baz quo qux\(aq +salt \(aq*\(aq disk.usage .ft P .fi .UNINDENT +.SS salt.modules.win_service +.sp +Windows Service module. .INDENT 0.0 -.TP -.B salt.modules.test.fib(num) -Return a Fibonacci sequence up to the passed number, and the time it took -to compute in seconds. Used for performance tests +.TP +.B salt.modules.win_service.disable(name) +Disable the named service to start at boot .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.fib 3 +salt \(aq*\(aq service.disable <service name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.test.get_opts() -Return the configuration options passed to this minion +.B salt.modules.win_service.disabled(name) +Check to see if the named service is disabled to start on boot .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.get_opts +salt \(aq*\(aq service.disabled <service name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.test.outputter(data) -Test the outputter, pass in data to return +.B salt.modules.win_service.enable(name) +Enable the named service to start at boot .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.outputter foobar +salt \(aq*\(aq service.enable <service name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.test.ping() -Just used to make sure the minion is up and responding -Return True +.B salt.modules.win_service.enabled(name) +Check to see if the named service is enabled to start on boot .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.ping +salt \(aq*\(aq service.enabled <service name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.test.version() -Return the version of salt on the minion +.B salt.modules.win_service.get_all() +Return all installed services .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq test.version +salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT -.SS salt.modules.tomcat -.sp -Support for Tomcat .INDENT 0.0 .TP -.B salt.modules.tomcat.fullversion() -Return all server information from catalina.sh version +.B salt.modules.win_service.get_disabled() +Return the disabled services .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq tomcat.fullversion +salt \(aq*\(aq service.get_disabled .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.tomcat.signal(signal=None) -Signals catalina to start, stop, securestart, forcestop. +.B salt.modules.win_service.get_enabled() +Return the enabled services .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq tomcat.signal start +salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.tomcat.version() -Return server version from catalina.sh version +.B salt.modules.win_service.getsid(name) +Return the sid for this windows service +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.win_service.restart(name) +Restart the named service .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq tomcat.version +salt \(aq*\(aq service.restart <service name> .ft P .fi .UNINDENT -.SS salt.modules.useradd -.sp -Manage users with the useradd command .INDENT 0.0 .TP -.B salt.modules.useradd.add(name, uid=None, gid=None, groups=None, home=False, shell=\(aq/bin/false\(aq) -Add a user to the minion +.B salt.modules.win_service.start(name) +Start the specified service .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.add name <uid> <gid> <groups> <home> <shell> +salt \(aq*\(aq service.start <service name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.useradd.chgid(name, gid) -Change the default group of the user +.B salt.modules.win_service.status(name, sig=None) +Return the status for a service, returns the PID or an empty string if the +service is running or not, pass a signature to use to find the service via +ps .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chgid foo 4376 +salt \(aq*\(aq service.status <service name> [service signature] .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.useradd.chgroups(name, groups, append=False) -Change the groups this user belongs to, add append to append the specified -groups +.B salt.modules.win_service.stop(name) +Stop the specified service .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chgroups foo wheel,root True +salt \(aq*\(aq service.stop <service name> .ft P .fi .UNINDENT +.SS salt.modules.win_useradd +.sp +Manage Windows users with the net user command +.sp +NOTE: This currently only works with local user accounts, not domain accounts .INDENT 0.0 .TP -.B salt.modules.useradd.chhome(name, home, persist=False) -Change the home directory of the user, pass true for persist to copy files -to the new home dir +.B salt.modules.win_useradd.add(name, password) +Add a user to the minion .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chhome foo /home/users/foo True +salt \(aq*\(aq user.add name password .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.useradd.chshell(name, shell) -Change the default shell of the user +.B salt.modules.win_useradd.addgroup(name, group) +Add user to a group .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chshell foo /bin/zsh +salt \(aq*\(aq user.addgroup username groupname .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.useradd.chuid(name, uid) -Change the uid for a named user +.B salt.modules.win_useradd.chhome(name, home) +Change the home directory of the user .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.chuid foo 4376 +salt \(aq*\(aq user.chhome foo \e\efileserver\ehome\efoo .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.useradd.delete(name, remove=False, force=False) -Remove a user from the minion +.B salt.modules.win_useradd.chprofile(name, profile) +Change the profile directory of the user .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.delete name True True +salt \(aq*\(aq user.chprofile foo \e\efileserver\eprofiles\efoo .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.useradd.getent() -Return the list of all info for all users +.B salt.modules.win_useradd.delete(name) +Remove a user from the minion .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.getent +salt \(aq*\(aq user.delete name .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.useradd.info(name) +.B salt.modules.win_useradd.info(name) Return user information .sp CLI Example: @@ -5458,358 +7701,365 @@ salt \(aq*\(aq user.info root .UNINDENT .INDENT 0.0 .TP -.B salt.modules.useradd.list_groups(name) +.B salt.modules.win_useradd.list_groups(name) Return a list of groups the named user belongs to .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq user.groups foo +salt \(aq*\(aq user.list_groups foo .ft P .fi .UNINDENT -.SS salt.modules.virt -.sp -Work with virtual machines managed by libvirt .INDENT 0.0 .TP -.B salt.modules.virt.create(vm_) -Start a defined domain +.B salt.modules.win_useradd.removegroup(name, group) +Remove user from a group .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.create <vm name> +salt \(aq*\(aq user.removegroup username groupname .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.create_xml_path(path) -Start a defined domain +.B salt.modules.win_useradd.setpassword(name, password) +Set a user\(aqs password .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.create_xml_path <path to xml file on the node> +salt \(aq*\(aq user.setpassword name password .ft P .fi .UNINDENT +.SS salt.modules.yumpkg +.sp +New in version 0.9.4: This module replaces the "yum" module in previous releases. It is backward +compatibile and uses the native yum Python interface instead of the CLI +interface. +.sp +Support for YUM .INDENT 0.0 .TP -.B salt.modules.virt.create_xml_str(xml) -Start a domain based on the xml passed to the function +.B salt.modules.yumpkg.available_version(name) +The available version of the package in the repository .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.create_xml_str <xml in string format> +salt \(aq*\(aq pkg.available_version <package name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.destroy(vm_) -Hard power down the virtual machine, this is equivalent to pulling the -power +.B salt.modules.yumpkg.clean_metadata() +Cleans local yum metadata. .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.destroy <vm name> +salt \(aq*\(aq pkg.clean_metadata .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.freecpu() -Return an int representing the number of unallocated cpus on this -hypervisor +.B salt.modules.yumpkg.install(pkgs, refresh=False, repo=\(aq\(aq, skip_verify=False) +Install the passed package(s) +.INDENT 7.0 +.TP +.B pkg +The name of the package to be installed +.TP +.B refresh +False +Clean out the yum database before executing +.TP +.B repo +(default) +Specify a package repository to install from +(e.g., \fByum \-\-enablerepo=somerepo\fP) +.TP +.B skip_verify +False +Skip the GPG verification check (e.g., \fB\-\-nogpgcheck\fP) +.UNINDENT .sp -CLI Example: +Return a dict containing the new package names and versions: .sp .nf .ft C -salt \(aq*\(aq virt.freemem +{\(aq<package>\(aq: {\(aqold\(aq: \(aq<old\-version>\(aq, + \(aqnew\(aq: \(aq<new\-version>\(aq]} .ft P .fi -.UNINDENT -.INDENT 0.0 -.TP -.B salt.modules.virt.freemem() -Return an int representing the amount of memory that has not been given -to virtual machines on this node .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.freemem +salt \(aq*\(aq pkg.install \(aqpackage package package\(aq .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.full_info() -Return the node_info, vm_info and freemem -.sp -CLI Example: +.B salt.modules.yumpkg.list_pkgs(*args) +List the packages currently installed in a dict: .sp .nf .ft C -salt \(aq*\(aq virt.full_info +{\(aq<package_name>\(aq: \(aq<version>\(aq} .ft P .fi -.UNINDENT -.INDENT 0.0 -.TP -.B salt.modules.virt.get_disks(vm_) -Return the disks of a named vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.get_disks <vm name> +salt \(aq*\(aq pkg.list_pkgs .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.get_graphics(vm_) -Returns the information on vnc for a given vm +.B salt.modules.yumpkg.purge(pkgs) +Yum does not have a purge, this function calls remove +.sp +Return a list containing the removed packages: .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.get_graphics <vm name> +salt \(aq*\(aq pkg.purge <package name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.get_xml(vm_) -Returns the xml for a given vm +.B salt.modules.yumpkg.refresh_db() +Since yum refreshes the database automatically, this runs a yum clean, +so that the next yum operation will have a clean database .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.get_xml <vm name> +salt \(aq*\(aq pkg.refresh_db .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.is_kvm_hyper() -Returns a bool whether or not this node is a hypervisor +.B salt.modules.yumpkg.remove(pkgs) +Removes packages with yum remove +.sp +Return a list containing the removed packages: .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.is_kvm_hyper +salt \(aq*\(aq pkg.remove <package,package,package> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.list_vms() -Return a list of virtual machine names on the minion +.B salt.modules.yumpkg.upgrade() +Run a full system upgrade, a yum upgrade .sp -CLI Example: +Return a dict containing the new package names and versions: .sp .nf .ft C -salt \(aq*\(aq virt.list_vms +{\(aq<package>\(aq: {\(aqold\(aq: \(aq<old\-version>\(aq, + \(aqnew\(aq: \(aq<new\-version>\(aq]} .ft P .fi -.UNINDENT -.INDENT 0.0 -.TP -.B salt.modules.virt.migrate(vm_, target) -Shared storage migration .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.migrate <vm name> <target hypervisor> +salt \(aq*\(aq pkg.upgrade .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.migrate_non_shared(vm_, target) -Attempt to execute non\-shared storage "all" migration +.B salt.modules.yumpkg.version(name) +Returns a version if the package is installed, else returns an empty string .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.migrate_non_shared <vm name> <target hypervisor> +salt \(aq*\(aq pkg.version <package name> .ft P .fi .UNINDENT +.SS salt.modules.yumpkg5 +.sp +Support for YUM .INDENT 0.0 .TP -.B salt.modules.virt.migrate_non_shared_inc(vm_, target) -Attempt to execute non\-shared storage "all" migration +.B salt.modules.yumpkg5.available_version(name) +The available version of the package in the repository .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.migrate_non_shared_inc <vm name> <target hypervisor> +salt \(aq*\(aq pkg.available_version <package name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.node_info() -Return a dict with information about this node +.B salt.modules.yumpkg5.install(pkg, refresh=False, repo=\(aq\(aq, skip_verify=False) +Install the passed package +.INDENT 7.0 +.TP +.B pkg +The name of the package to be installed +.TP +.B refresh +False +Clean out the yum database before executing +.TP +.B repo +(default) +Specify a package repository to install from +(e.g., \fByum \-\-enablerepo=somerepo\fP) +.TP +.B skip_verify +False +Skip the GPG verification check (e.g., \fB\-\-nogpgcheck\fP) +.UNINDENT .sp -CLI Example: +Return a dict containing the new package names and versions: .sp .nf .ft C -salt \(aq*\(aq virt.node_info +{\(aq<package>\(aq: {\(aqold\(aq: \(aq<old\-version>\(aq, + \(aqnew\(aq: \(aq<new\-version>\(aq]} .ft P .fi -.UNINDENT -.INDENT 0.0 -.TP -.B salt.modules.virt.pause(vm_) -Pause the named vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.pause <vm name> +salt \(aq*\(aq pkg.install <package name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.purge(vm_, dirs=False) -Recursively destroy and delete a virtual machine, pass True for dir\(aqs to -also delete the directories containing the virtual machine disk images \- -USE WITH EXTREME CAUTION! -.sp -CLI Example: +.B salt.modules.yumpkg5.list_pkgs() +List the packages currently installed in a dict: .sp .nf .ft C -salt \(aq*\(aq virt.purge <vm name> +{\(aq<package_name>\(aq: \(aq<version>\(aq} .ft P .fi -.UNINDENT -.INDENT 0.0 -.TP -.B salt.modules.virt.resume(vm_) -Resume the named vm .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.resume <vm name> +salt \(aq*\(aq pkg.list_pkgs .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.seed_non_shared_migrate(disks, force=False) -Non shared migration requires that the disks be present on the migration -destination, pass the disks information via this function, to the -migration destination before executing the migration. +.B salt.modules.yumpkg5.purge(pkg) +Yum does not have a purge, this function calls remove +.sp +Return a list containing the removed packages: .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.seed_non_shared_migrate <disks> +salt \(aq*\(aq pkg.purge <package name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.set_autostart(vm_, state=\(aqon\(aq) -Set the autostart flag on a VM so that the VM will start with the host -system on reboot. -.INDENT 7.0 -.TP -.B CLI Example:: -salt "*" virt.enable_autostart <vm name> <on | off> -.UNINDENT -.UNINDENT -.INDENT 0.0 -.TP -.B salt.modules.virt.shutdown(vm_) -Send a soft shutdown signal to the named vm +.B salt.modules.yumpkg5.refresh_db() +Since yum refreshes the database automatically, this runs a yum clean, +so that the next yum operation will have a clean database .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.shutdown <vm name> +salt \(aq*\(aq pkg.refresh_db .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.undefine(vm_) -Remove a defined vm, this does not purge the virtual machine image, and -this only works if the vm is powered down +.B salt.modules.yumpkg5.remove(pkg) +Remove a single package with yum remove +.sp +Return a list containing the removed packages: .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.undefine <vm name> +salt \(aq*\(aq pkg.remove <package name> .ft P .fi .UNINDENT .INDENT 0.0 .TP -.B salt.modules.virt.virt_type() -Returns the virtual machine type as a string +.B salt.modules.yumpkg5.upgrade() +Run a full system upgrade, a yum upgrade .sp -CLI Example: +Return a dict containing the new package names and versions: .sp .nf .ft C -salt \(aq*\(aq virt.virt_type +{\(aq<package>\(aq: {\(aqold\(aq: \(aq<old\-version>\(aq, + \(aqnew\(aq: \(aq<new\-version>\(aq]} .ft P .fi -.UNINDENT -.INDENT 0.0 -.TP -.B salt.modules.virt.vm_info() -Return detailed information about the vms on this hyper in a dict: +.sp +CLI Example: .sp .nf .ft C -{\(aqcpu\(aq: <int>, -\(aqmaxMem\(aq: <int>, -\(aqmem\(aq: <int>, -\(aqstate\(aq: \(aq<state>\(aq, -\(aqcputime\(aq <int>} +salt \(aq*\(aq pkg.upgrade .ft P .fi +.UNINDENT +.INDENT 0.0 +.TP +.B salt.modules.yumpkg5.version(name) +Returns a version if the package is installed, else returns an empty string .sp CLI Example: .sp .nf .ft C -salt \(aq*\(aq virt.vm_info +salt \(aq*\(aq pkg.version <package name> .ft P .fi .UNINDENT @@ -5844,7 +8094,7 @@ grains need to be static data. The core module in the grains package is where the main grains are loaded by the salt minion and the principal example of how to write grains: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/grains/core.py\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/grains/core.py\fP .SH RETURNERS .sp By default the return values of the commands sent to the salt minions are @@ -5897,7 +8147,7 @@ serializes the data as json and sets it in redis. .SS Examples .sp The collection of builtin salt returners can be found here: -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/returners\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/returners\fP .SH FULL LIST OF BUILTIN RETURNERS .TS center; @@ -5910,13 +8160,21 @@ The local returner is used to test the returner interface, it just prints the T} _ T{ +\fBcassandra_return\fP +T} T{ +Return data to a Cassandra ColumFamily +T} +_ +T{ \fBmongo_return\fP T} T{ +Return data to a mongodb server T} _ T{ \fBredis_return\fP T} T{ +Return data to a redis server T} _ .TE @@ -5929,6 +8187,48 @@ return data to the console to verify that it is being passed properly .B salt.returners.local.returner(ret) Print the return data to the terminal to verify functionality .UNINDENT +.SS salt.returners.cassandra_return +.sp +Return data to a Cassandra ColumFamily +.sp +Here\(aqs an example Keyspace/ColumnFamily setup that works with this +returner: +.sp +.nf +.ft C +create keyspace salt; +use salt; +create column family returns + with key_validation_class=\(aqUTF8Type\(aq + and comparator=\(aqUTF8Type\(aq + and default_validation_class=\(aqUTF8Type\(aq; +.ft P +.fi +.INDENT 0.0 +.TP +.B salt.returners.cassandra_return.returner(ret) +Return data to a Cassandra ColumnFamily +.UNINDENT +.SS salt.returners.mongo_return +.sp +Return data to a mongodb server +.sp +This is the default interface for returning data for the butter statd subsytem +.INDENT 0.0 +.TP +.B salt.returners.mongo_return.returner(ret) +Return data to a mongodb server +.UNINDENT +.SS salt.returners.redis_return +.sp +Return data to a redis server +This is a VERY simple example for pushing data to a redis server and is not +necessarily intended as a usable interface. +.INDENT 0.0 +.TP +.B salt.returners.redis_return.returner(ret) +Return data to a redis data store +.UNINDENT .SH FAILHARD GLOBAL OPTION .sp Normally, when a state fails Salt continues to execute the remainder of the @@ -6357,7 +8657,7 @@ files. The available renderers can be found in the renderers directory in the Salt source code: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/renderers\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/renderers\fP .sp By default sls files are rendered using jinja as a templating engine, and yaml as the serialization format. Since the rendering system can be extended simply @@ -6518,6 +8818,18 @@ Mount Management T} _ T{ +\fBmysql_database\fP +T} T{ +MySQL Database Management +T} +_ +T{ +\fBmysql_user\fP +T} T{ +MySQL User Management +T} +_ +T{ \fBpkg\fP T} T{ Package Management @@ -6547,6 +8859,12 @@ T} T{ User Management T} _ +T{ +\fBvirtualenv\fP +T} T{ +virtualenv management +T} +_ .TE .SS salt.states.cmd .SS Command Executions @@ -6947,7 +9265,7 @@ directory will be deleted unless it is required. .UNINDENT .INDENT 0.0 .TP -.B salt.states.file.managed(name, source=None, user=None, group=None, mode=None, template=None, makedirs=False, context=None, defaults=None, __env__=\(aqbase\(aq) +.B salt.states.file.managed(name, source=None, source_hash=\(aq\(aq, user=None, group=None, mode=None, template=None, makedirs=False, context=None, defaults=None, __env__=\(aqbase\(aq) Manage a given file, this function allows for a file to be downloaded from the salt master and potentially run through a templating system. .INDENT 7.0 @@ -6956,11 +9274,21 @@ the salt master and potentially run through a templating system. The location of the file to manage .TP .B source -The source file, this file is located on the salt master file server -and is specified with the salt:// protocol. If the file is located on +The source file to download to the minion, this source file can be +hosted on either the salt master server, or on an http or ftp server. +For files hosted on the salt file server, if the file is located on the master in the directory named spam, and is called eggs, the source string is salt://spam/eggs. If source is left blank or None, the file -will be created as an empty file and the content will not be managed +will be created as an empty file and the content will not be managed +.sp +If the file is hosted on a http or ftp server then the source_hash +argument is also required +.TP +.B source_hash: +This can be either a file which contains a source hash string for +the source, or a source hash string. The source hash string is the +hash algorithm followed by the hash of the file: +md5=e138491e9d5b97023cea823fe17bac22 .TP .B user The user to own the file, this defaults to the user salt is running as @@ -7261,6 +9589,74 @@ default to True Set if the mount should be saved in the fstab, default to True .UNINDENT .UNINDENT +.SS salt.states.mysql_database +.SS MySQL Database Management +.sp +The mysql_database module is used to create and manage MySQL databases, databases can be set +as either absent or present +.sp +.nf +.ft C +frank: + mysql_database: + \- present +.ft P +.fi +.INDENT 0.0 +.TP +.B salt.states.mysql_database.absent(name) +Ensure that the named database is absent +.INDENT 7.0 +.TP +.B name +The name of the database to remove +.UNINDENT +.UNINDENT +.INDENT 0.0 +.TP +.B salt.states.mysql_database.present(name) +Ensure that the named database is present with the specified properties +.INDENT 7.0 +.TP +.B name +The name of the database to manage +.UNINDENT +.UNINDENT +.SS salt.states.mysql_user +.SS MySQL User Management +.sp +The mysql_database module is used to create and manage MySQL databases, databases can be set +as either absent or present +.sp +.nf +.ft C +frank: + mysql_user: + \- present + \- host: localhost + \- password: bobcat +.ft P +.fi +.INDENT 0.0 +.TP +.B salt.states.mysql_user.absent(name, host=\(aqlocalhost\(aq) +Ensure that the named user is absent +.INDENT 7.0 +.TP +.B name +The name of the user to remove +.UNINDENT +.UNINDENT +.INDENT 0.0 +.TP +.B salt.states.mysql_user.present(name, host=\(aqlocalhost\(aq, password=None) +Ensure that the named user is present with the specified properties +.INDENT 7.0 +.TP +.B name +The name of the user to manage +.UNINDENT +.UNINDENT .SS salt.states.pkg .SS Package Management .sp @@ -7566,6 +9962,25 @@ A password hash to set for the user The login shell, defaults to /bin/bash .UNINDENT .UNINDENT +.SS salt.states.virtualenv +.sp +virtualenv management +.INDENT 0.0 +.TP +.B salt.states.virtualenv.manage(name, venv_bin=\(aq\(aq, requirements=\(aq\(aq, no_site_packages=False, system_site_packages=False, clear=False, python=\(aq\(aq, extra_search_dir=\(aq\(aq, never_download=False, prompt=\(aq\(aq, __env__=\(aqbase\(aq) +Create a virtualenv and optionally manage it with pip +.INDENT 7.0 +.TP +.B name +Path to the virtualenv +.TP +.B requirements +Path to a pip requirements file. If the path begins with \fBsalt://\fP +the file will be transfered from the master file server. +.UNINDENT +.sp +Also accepts any kwargs that the virtualenv module will. +.UNINDENT .SH RENDERERS .sp The Salt state system operates by gathering information from simple data @@ -7594,7 +10009,7 @@ derived from the file. The best place to find examples of renderers is in the Salt source code. The renderers included with Salt can be found here: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/renderers\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/renderers\fP .sp Here is a simple jinja + yaml example: .sp @@ -7635,6 +10050,7 @@ _ T{ \fBjson_mako\fP T} T{ +Process json with the Mako templating engine T} _ T{ @@ -7646,6 +10062,7 @@ _ T{ \fByaml_mako\fP T} T{ +Process yaml with the Mako templating engine T} _ T{ @@ -7666,6 +10083,17 @@ high data format for salt states. .B salt.renderers.json_jinja.render(template_file, env=\(aq\(aq, sls=\(aq\(aq) Render the data passing the functions and grains into the rendering system .UNINDENT +.SS salt.renderers.json_mako +.sp +Process json with the Mako templating engine +.sp +This renderer will take a json file with the Mako template and render it to a +high data format for salt states. +.INDENT 0.0 +.TP +.B salt.renderers.json_mako.render(template) +Render the data passing the functions and grains into the rendering system +.UNINDENT .SS salt.renderers.yaml_jinja .sp The default rendering engine, process yaml with the jinja2 templating engine @@ -7677,6 +10105,17 @@ high data format for salt states. .B salt.renderers.yaml_jinja.render(template_file, env=\(aq\(aq, sls=\(aq\(aq) Render the data passing the functions and grains into the rendering system .UNINDENT +.SS salt.renderers.yaml_mako +.sp +Process yaml with the Mako templating engine +.sp +This renderer will take a yaml file within a mako template and render it to a +high data format for salt states. +.INDENT 0.0 +.TP +.B salt.renderers.yaml_mako.render(template, env=\(aq\(aq, sls=\(aq\(aq) +Render the data passing the functions and grains into the rendering system +.UNINDENT .SS salt.renderers.py .sp Pure python state renderer @@ -7716,7 +10155,7 @@ contains a function called \fBfoo\fP then the function could be called with: .sp The best examples of runners can be found in the Salt source: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/runners\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/runners\fP .sp A simple runner that returns a well formated list of the minons that are responding to salt calls would look like this: @@ -7827,7 +10266,7 @@ extra information needs to be sent with the publications, the order_masters option makes sure that the extra data is sent out. .SS Running the Syndic .sp -The Syndic is a separate daemon that needs to be started on the master that is +The Syndic is a seperate daemon that needs to be started on the master that is controlled by a higher master. Starting the Syndic daemon is the same as starting the other Salt daemons. .sp @@ -8041,6 +10480,7 @@ def get_file(path, dest, env=\(aqbase\(aq): .sp .nf .ft C +# DO NOT MODIFY THIS FILE. Copy it to: /etc/salt/master ##### Primary configuration settings ##### ########################################## # The address of the interface to bind to @@ -8049,6 +10489,9 @@ def get_file(path, dest, env=\(aqbase\(aq): # The port used by the publisher #publish_port: 4505 +# The user to run salt +#user: root + # The number of worker threads to start, these threads are used to manage # return calls made from minions to the master, if the master seems to be # running slowly, increase the number of threads @@ -8128,9 +10571,9 @@ def get_file(path, dest, env=\(aqbase\(aq): # prod: # \- /srv/salt/prod/services # \- /srv/salt/prod/states -# +# # Default: -#file_roots: +#file_roots: # base: # \- /srv/salt @@ -8149,7 +10592,7 @@ def get_file(path, dest, env=\(aqbase\(aq): # syndic servers(s) below it set the "order_masters" setting to True, if this # is a master that will be running a syndic daemon for passthrough the # "syndic_master" setting needs to be set to the location of the master server -# to receive commands from +# to recieve commands from # # Set the order_masters setting to True if this master will command lower # masters\(aq syndic interfaces @@ -8226,7 +10669,7 @@ def get_file(path, dest, env=\(aqbase\(aq): ########################################## # Node groups allow for logical groupings of minion nodes. # A group consists of a group name and a compound target. -# +# # nodegroups: # group1: \(aqL@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com\(aq, # group2: \(aqG@os:Debian and foo.domain.com\(aq, @@ -8238,6 +10681,7 @@ def get_file(path, dest, env=\(aqbase\(aq): .sp .nf .ft C +# DO NOT MODIFY THIS FILE. Copy it to: /etc/salt/minion ##### Primary configuration settings ##### ########################################## # Set the location of the salt master server, if the master server cannot be @@ -8247,6 +10691,9 @@ def get_file(path, dest, env=\(aqbase\(aq): # Set the post used by the master reply and authentication server #master_port: 4506 +# The user to run salt +#user: root + # The root directory prepended to these options: pki_dir, cachedir, log_file. #root_dir: / @@ -8268,10 +10715,16 @@ def get_file(path, dest, env=\(aqbase\(aq): # Where cache data goes #cachedir: /var/cache/salt +# The minion can locally cache the return data from jobs sent to it, this +# can be a good way to keep track minion side of the jobs the minion has +# executed. By default this feature is disabled, to enable set cache_jobs +# to True +#cache_jobs: False + # When waiting for a master to accept the minion\(aqs public key, salt will -# contiuously attempt to reconnect until successful. This is the time, in +# continuously attempt to reconnect until successful. This is the time, in # seconds, between those reconnection attempts. -# acceptance_wait_time = 10 +#acceptance_wait_time = 10 @@ -8412,6 +10865,17 @@ The network port to set up the publication interface publish_port: 4505 .ft P .fi +.SS \fBuser\fP +.sp +Default: \fBroot\fP +.sp +The user to run the Salt processes +.sp +.nf +.ft C +user: root +.ft P +.fi .SS \fBworker_threads\fP .sp Default: \fB5\fP @@ -8443,6 +10907,12 @@ Default: \fB/\fP .sp The system root direcotry to oporate from, change this to make Salt run from an alternative root +.sp +.nf +.ft C +root_dir: / +.ft P +.fi .SS \fBpki_dir\fP .sp Default: \fB/etc/salt/pki\fP @@ -8608,7 +11078,7 @@ master. Using the syndic is simple, if this is a master that will have syndic servers(s) below it set the "order_masters" setting to True, if this is a master that will be running a syndic daemon for passthrough the "syndic_master" setting needs to be set to the location of the master server -to receive commands from +to recieve commands from .SS \fBorder_masters\fP .sp Default: \fBFalse\fP @@ -8760,6 +11230,17 @@ option on the salt master. master_port: 4506 .ft P .fi +.SS \fBuser\fP +.sp +Default: \fBroot\fP +.sp +The user to run the Salt processes +.sp +.nf +.ft C +user: root +.ft P +.fi .SS \fBpki_dir\fP .sp Default: \fB/etc/salt/pki\fP @@ -8808,6 +11289,21 @@ The location for minion cache data. cachedir: /var/cache/salt .ft P .fi +.SS \fBcache_jobs\fP +.sp +Default: \fBFalse\fP +.sp +The minion can locally cache the return data from jobs sent to it, this +can be a good way to keep track minion side of the jobs the minion has +executed. By default this feature is disabled, to enable set cache_jobs +to True +.sp +.nf +.ft C +cache_jobs: False +.ft P +.fi +.SS \fBacceptance_wait_time\fP .sp Default: \fB10\fP .sp @@ -9343,6 +11839,18 @@ Run the salt master as a daemon .B \-c CONFIG, \-\-config=CONFIG The master configuration file to use, the default is /etc/salt/master .UNINDENT +.INDENT 0.0 +.TP +.B \-u USER, \-\-user=USER +Specify user to run minion +.UNINDENT +.INDENT 0.0 +.TP +.B \-l LOG_LEVEL, \-\-log\-level=LOG_LEVEL +Console log level. One of \fBinfo\fP, \fBnone\fP, \fBgarbage\fP, +\fBtrace\fP, \fBwarning\fP, \fBerror\fP, \fBdebug\fP. For the logfile +settings see the config file. Default: \fBwarning\fP. +.UNINDENT .SH SALT-MINION .sp The salt minion daemon, receives commands from a remote salt master. @@ -9369,6 +11877,18 @@ Run the salt minion as a daemon .B \-c CONFIG, \-\-config=CONFIG The minion configuration file to use, the default is /etc/salt/minion .UNINDENT +.INDENT 0.0 +.TP +.B \-u USER, \-\-user=USER +Specify user to run minion +.UNINDENT +.INDENT 0.0 +.TP +.B \-l LOG_LEVEL, \-\-log\-level=LOG_LEVEL +Console log level. One of \fBinfo\fP, \fBnone\fP, \fBgarbage\fP, +\fBtrace\fP, \fBwarning\fP, \fBerror\fP, \fBdebug\fP. For the logfile +settings see the config file. Default: \fBwarning\fP. +.UNINDENT .SH SALT-KEY .SS Synopsis .sp @@ -9940,7 +12460,7 @@ use the file extension “.pyx” and the minion module will be compiled when the minion is started. An example cython module is included in the main distribution called cytest.pyx: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/modules/cytest.pyx\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/modules/cytest.pyx\fP .SS Dynamic Returners \- .sp By default salt returns command data back to the salt master, but now salt can @@ -9954,7 +12474,7 @@ data so anything from MySQL, redis, mongodb and more! .sp There are 2 simple stock returners in the returners directory: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/returners\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/returners\fP .sp The documentation on writing returners will be added to the wiki shortly, and returners can be written in pure python, or in cython. @@ -9970,7 +12490,7 @@ Information on how to use this simple addition has been added to the wiki: The test module has an example of using the __opts__ dict, and how to set default options: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/modules/test.py\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/modules/test.py\fP .SS Advanced Minion Threading: .sp In 0.7.0 the minion would block after receiving a command from the master, now @@ -9982,7 +12502,7 @@ exploit the negative aspects of the Python GIL to run faster and more reliably, but simple calls will still be faster with python threading. The configuration option can be found in the minion configuration file: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/conf/minion\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/conf/minion\fP .sp Lowered Supported Python to 2.6 \- .sp @@ -10060,7 +12580,7 @@ The system for loading salt modules has been pulled out of the minion class to be a standalone module, this has enabled more dynamic loading of Salt modules and enables many of the updates in 0.8.7 – .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/loader.py\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/loader.py\fP .sp Salt Job ids are now microsecond precise, this was needed to repair a race condition unveiled by the speed improvements in the new ZeroMQ topology. @@ -10336,7 +12856,7 @@ The minion and master classes have been redesigned to allow for specialized minion and master servers to be easily created. An example on how this is done for the master can be found in the \fBmaster.py\fP salt module: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/master.py\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/master.py\fP .sp The \fBMaster\fP class extends the \fBSMaster\fP class and set up the main master server. @@ -10344,7 +12864,7 @@ server. The minion functions can now also be easily added to another application via the \fBSMinion\fP class, this class can be found in the \fBminion.py\fP module: .sp -\fI\%https://github.com/saltstack/salt/blob/v0.9.5/salt/minion.py\fP +\fI\%https://github.com/saltstack/salt/blob/v0.9.6/salt/minion.py\fP .SS Cleaner Key Management .sp This release changes some of the key naming to allow for multiple master keys @@ -10870,6 +13390,10 @@ Salt 0.9.5 is one of the largest steps forward in the development of Salt. 0.9.5 comes with many milestones, this release has seen the community of developers grow out to an international team of 46 code contributors and has many feature additions, feature enhancements, bug fixes and speed improvements. +.IP Warning +Be sure to \fIread the upgrade instructions\fP about the +switch to msgpack before upgrading! +.RE .SS Community .sp Nothing has proven to have more value to the development of Salt that the @@ -10880,36 +13404,66 @@ expandability of Salt is as exponential as I originally intended. 0.9.5 has received over 600 additional commits since 0.9.4 with a swath of new commiters. The following individuals have contributed to the development of 0.9.5: -.sp +.INDENT 0.0 +.IP \(bu 2 Aaron Bull Schaefer +.IP \(bu 2 Antti Kaihola +.IP \(bu 2 Bas Tichelaar +.IP \(bu 2 Brad Barden +.IP \(bu 2 Brian Wagner +.IP \(bu 2 Byron Clark +.IP \(bu 2 Chris Scheller +.IP \(bu 2 Christer Edwards +.IP \(bu 2 Clint Savage +.IP \(bu 2 Corey Quinn +.IP \(bu 2 David Boucha +.IP \(bu 2 Eivind Uggedal +.IP \(bu 2 Eric Poelke +.IP \(bu 2 Evan Borgstrom +.IP \(bu 2 Jed Glazner +.IP \(bu 2 Jeff Schroeder +.IP \(bu 2 Jeffrey C. Ollie +.IP \(bu 2 Jonas Buckner +.IP \(bu 2 Kent Tenney +.IP \(bu 2 Martin Schnabel +.IP \(bu 2 Maxim Burgerhout +.IP \(bu 2 Mitch Anderson +.IP \(bu 2 Nathaniel Whiteinge +.IP \(bu 2 Seth House +.IP \(bu 2 Thomas S Hatch +.IP \(bu 2 Thomas Schreiber +.IP \(bu 2 Tor Hveem +.IP \(bu 2 lzyeval +.IP \(bu 2 syphernl +.UNINDENT .sp This makes 21 new developers since 0.9.4 was released! .sp @@ -10932,20 +13486,29 @@ This move introduces a few changes to Salt. First off, Salt is no longer a "noarch" package, since the msgpack lib is written in C. Salt 0.9.5 will also have compatibility issues with 0.9.4 with the default configuration. .sp -We have gone through great lengths to avoid backwards compatibility issues -with Salt, but changing the serialization medium was going to create issues -regardless. Salt 0.9.5 is somewhat backwards compatible with earlier minions. -A 0.9.5 master can command older minions, but only if the ?serial? config -value in the master is set to ?pickle?. This will tell the master to publish -messages in pickle format and will allow the master to receive messages in -both msgpack and pickle formats. -.sp -Therefore the suggested methods for upgrading are either to just upgrade -everything at once, or to upgrade the master to 0.9.5, set "serial: pickle" in -the master config, upgrade the minions, and then remove the serial option from -the config. Since pickles can be used as a security exploit the ability for a -master to accept pickles from minions at all will be removed in a future -release. +We have gone through great lengths to avoid backwards compatibility issues with +Salt, but changing the serialization medium was going to create issues +regardless. Salt 0.9.5 is somewhat backwards compatible with earlier minions. A +0.9.5 master can command older minions, but only if the \fBserial\fP +config value in the master is set to \fBpickle\fP. This will tell the master to +publish messages in pickle format and will allow the master to receive messages +in both msgpack and pickle formats. +.sp +Therefore \fBthe suggested methods for upgrading\fP are either to just upgrade +everything at once, or: +.INDENT 0.0 +.IP 1. 3 +Upgrade the master to 0.9.5 +.IP 2. 3 +Set \fBserial\fP to \fBpickle\fP in the master config +.IP 3. 3 +Upgrade the minions +.IP 4. 3 +Remove the \fBserial\fP option from the master config +.UNINDENT +.sp +Since pickles can be used as a security exploit the ability for a master to +accept pickles from minions at all will be removed in a future release. .SS C Bindings for YAML .sp All of the YAML rendering is now done with the YAML C bindings. This speeds up @@ -10971,30 +13534,33 @@ in a number of ways: Now when salt modules are deployed to a minion via the state system as a file, then the modules will be automatically loaded into the active running minion \- no restart required \- and into the active running state. So custom state -.INDENT 0.0 -.INDENT 3.5 modules can be deployed and used in the same state run. -.UNINDENT -.UNINDENT .SS Modules via Module Environment Directories .sp Under the file_roots each environment can now have directories that are used to deploy large groups of modules. These directories sync modules at the beginning of a state run on the minion, or can be manually synced via the Salt -module "saltutil.sync_all". +module \fBsalt.modules.saltutil.sync_all\fP. .sp The directories are named: -_modules -_states -_grains -_renderers -_returners +.INDENT 0.0 +.IP \(bu 2 +\fB_modules\fP +.IP \(bu 2 +\fB_states\fP +.IP \(bu 2 +\fB_grains\fP +.IP \(bu 2 +\fB_renderers\fP +.IP \(bu 2 +\fB_returners\fP +.UNINDENT .sp The modules are pushed to their respective scopes on the minions. .SS Module Reloading .sp Modules can now be reloaded without restarting the minion, this is done by -calling the sys.reload_modules function. +calling the \fBsalt.modules.sys.reload_modules\fP function. .sp But wait, there\(aqs more! Now when a salt module of any type is added via states the modules will be automatically reloaded, allowing for modules to be @@ -11008,9 +13574,9 @@ A great deal of demand has existed for adding the capability to set services to be started at boot in the service module. This feature also comes with an overhaul of the service modules and initial systemd support. .sp -This means that the service state can now accept "\- enable: True" to make sure -a service is enabled at boot, and "\- enable: False" to make sure it is -disabled. +This means that the \fBservice state\fP can now +accept \fB\- enable: True\fP to make sure a service is enabled at boot, and \fB\- +enable: False\fP to make sure it is disabled. .SS Compound Target .sp A new target type has been added to the lineup, the compound target. In @@ -11020,10 +13586,14 @@ specific target type, but now many target specifications can be declared. These targets can also be separated by and/or operators, so certain properties can be used to omit a node: .sp -salt \-C \(aqwebserv* and \fI\%G@os\fP:Debian or \fI\%E@db.*\fP\(aq test.ping +.nf +.ft C +salt \-C \(aqwebserv* and G@os:Debian or E@db.*\(aq test.ping +.ft P +.fi .sp will match all minions with ids starting with webserv via a glob and minions -matching the os:Debian grain. Or minions that match the "db.*" regular +matching the \fBos:Debian\fP grain. Or minions that match the \fBdb.*\fP regular expression. .SS Node Groups .sp @@ -11031,16 +13601,22 @@ Often the convenience of having a predefined group of minions to execute targets on is desired. This can be accomplished with the new nodegroups feature. Nodegroups allow for predefined compound targets to be declared in the master configuration file: -.INDENT 0.0 -.TP -.B nodegroups: -group1: \fI\%'L@foo.domain.com\fP,bar.domain.com,baz.domain.com and bl*.domain.com\(aq -group2: \fI\%'G@os\fP:Debian and foo.domain.com\(aq -.UNINDENT .sp -And then used via the \-N option: +.nf +.ft C +nodegroups: + group1: \(aqL@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com\(aq + group2: \(aqG@os:Debian and foo.domain.com\(aq +.ft P +.fi +.sp +And then used via the \fB\-N\fP option: .sp +.nf +.ft C salt \-N group1 test.ping +.ft P +.fi .SS Minion Side Data Store .sp The data module introduces the initial approach into storing persistent data on @@ -11058,8 +13634,8 @@ this includes hardware data, os data and salt specific data. In the past the salt query system, which would display the data from recent executions would be displayed in pure python, and it was unreadable. .sp -0.9.5 has added the outputter system to the \-Q option, thus enabling the salt -query system to return readable output. +0.9.5 has added the outputter system to the \fB\-Q\fP option, thus enabling the +salt query system to return readable output. .SS Packaging Updates .sp Huge strides have been made in packaging Salt for distributions. These @@ -11086,9 +13662,14 @@ Ubuntu and the package data that has been prepared is being pushed through the needed channels for inclusion. .sp These packages have been prepared with the help of: +.INDENT 0.0 +.IP \(bu 2 Corey +.IP \(bu 2 Aaron Toponce +.IP \(bu 2 and\(ga +.UNINDENT .SS More to Come .sp We are actively seeking inclusion in more distributions. Primarily getting @@ -11111,55 +13692,56 @@ visual issues to repairing misleading data. A custom exception module has been added to throw salt specific exceptions. This allows Salt to give much more granular error information. .SS New Modules -.SS data +.SS \fBdata\fP .sp The new data module manages a persistent datastore on the minion. Big thanks to bastichelaar for his help refining this module -.SS freebsdkmod +.SS \fBfreebsdkmod\fP .sp FreeBSD kernel modules can now be managed in the same way Salt handles Linux kernel modules. +.sp This module was contributed thanks to the efforts of Christer Edwards -.SS gentoo_service +.SS \fBgentoo_service\fP .sp Support has been added for managing services in Gentoo. Now Gentoo services can be started, stopped, restarted, enabled, disabled and viewed. -.SS pip +.SS \fBpip\fP .sp The pip module introduces management for pip installed applications. Thanks goes to whitinge for the addition of the pip module -.SS rh_service +.SS \fBrh_service\fP .sp The rh_service module enables Red Hat and Fedora specific service management. Now Red Hat like systems come with extensive management of the classic init system used by Red Hat -.SS saltutil +.SS \fBsaltutil\fP .sp The saltutil module has been added as a place to hold functions used in the maintenance and management of salt itself. Saltutil is used to salt the salt minion. The saltutil module is presently used only to sync extension modules from the master server. -.SS systemd +.SS \fBsystemd\fP .sp Systemd support has been added to Salt, now systems using this next generation init system are supported on systems running systemd. -.SS virtualenv +.SS \fBvirtualenv\fP .sp The virtualenv module has been added to allow salt to create virtual python environments. Thanks goes to whitinge for the addition of the virtualenv module -.SS win_disk +.SS \fBwin_disk\fP .sp Support for gathering disk information on Microsoft Windows minions The windows modules come courtesy of Utah_Dave -.SS win_service +.SS \fBwin_service\fP .sp The win_service module adds service support to Salt for Microsoft Windows services -.SS win_useradd +.SS \fBwin_useradd\fP .sp Salt can now manage local users on Microsoft Windows Systems -.SS yumpkg5 +.SS \fByumpkg5\fP .sp The yumpkg module introduces in 0.9.4 uses the yum api to interact with the yum package manager. Unfortunately, on Red Hat 5 systems salt does not have @@ -11169,27 +13751,28 @@ needs to run under python 2.6. The yumpkg5 module bypasses this issue by shelling out to yum on systems where the yum api is not available. .SS New States -.SS mysql_database +.SS \fBmysql_database\fP .sp The new mysql_database state adds the ability to systems running a mysql server to manage the existence of mysql databases. .sp The mysql states are thanks to syphernl -.SS mysql_user +.SS \fBmysql_user\fP .sp The mysql_user state enables mysql user management. -.SS virtualenv +.SS \fBvirtualenv\fP .sp The virtualenv state can manage the state of python virtual environments. Thanks to Whitinge for the virtualenv state .SS New Returners -.SS cassandra_returner +.SS \fBcassandra_returner\fP .sp -A returnerer allowing Salt to send data to a cassandra server. +A returner allowing Salt to send data to a cassandra server. Thanks to Byron Clark for contributing this returner .SH AUTHOR Thomas S. Hatch <thatch@gmail.com> and many others, please see the Authors file .SH COPYRIGHT 2011, Thomas S. Hatch .\" Generated by docutils manpage writer. +.\" .