id
int32 0
252k
| repo
stringlengths 7
55
| path
stringlengths 4
127
| func_name
stringlengths 1
88
| original_string
stringlengths 75
19.8k
| language
stringclasses 1
value | code
stringlengths 75
19.8k
| code_tokens
list | docstring
stringlengths 3
17.3k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 87
242
|
|---|---|---|---|---|---|---|---|---|---|---|---|
15,700
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.releaseNativeOverlayHandle
|
def releaseNativeOverlayHandle(self, ulOverlayHandle, pNativeTextureHandle):
"""
Release the pNativeTextureHandle provided from the GetOverlayTexture call, this allows the system to free the underlying GPU resources for this object,
so only do it once you stop rendering this texture.
"""
fn = self.function_table.releaseNativeOverlayHandle
result = fn(ulOverlayHandle, pNativeTextureHandle)
return result
|
python
|
def releaseNativeOverlayHandle(self, ulOverlayHandle, pNativeTextureHandle):
"""
Release the pNativeTextureHandle provided from the GetOverlayTexture call, this allows the system to free the underlying GPU resources for this object,
so only do it once you stop rendering this texture.
"""
fn = self.function_table.releaseNativeOverlayHandle
result = fn(ulOverlayHandle, pNativeTextureHandle)
return result
|
[
"def",
"releaseNativeOverlayHandle",
"(",
"self",
",",
"ulOverlayHandle",
",",
"pNativeTextureHandle",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"releaseNativeOverlayHandle",
"result",
"=",
"fn",
"(",
"ulOverlayHandle",
",",
"pNativeTextureHandle",
")",
"return",
"result"
] |
Release the pNativeTextureHandle provided from the GetOverlayTexture call, this allows the system to free the underlying GPU resources for this object,
so only do it once you stop rendering this texture.
|
[
"Release",
"the",
"pNativeTextureHandle",
"provided",
"from",
"the",
"GetOverlayTexture",
"call",
"this",
"allows",
"the",
"system",
"to",
"free",
"the",
"underlying",
"GPU",
"resources",
"for",
"this",
"object",
"so",
"only",
"do",
"it",
"once",
"you",
"stop",
"rendering",
"this",
"texture",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5124-L5132
|
15,701
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.getOverlayTextureSize
|
def getOverlayTextureSize(self, ulOverlayHandle):
"""Get the size of the overlay texture"""
fn = self.function_table.getOverlayTextureSize
pWidth = c_uint32()
pHeight = c_uint32()
result = fn(ulOverlayHandle, byref(pWidth), byref(pHeight))
return result, pWidth.value, pHeight.value
|
python
|
def getOverlayTextureSize(self, ulOverlayHandle):
"""Get the size of the overlay texture"""
fn = self.function_table.getOverlayTextureSize
pWidth = c_uint32()
pHeight = c_uint32()
result = fn(ulOverlayHandle, byref(pWidth), byref(pHeight))
return result, pWidth.value, pHeight.value
|
[
"def",
"getOverlayTextureSize",
"(",
"self",
",",
"ulOverlayHandle",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getOverlayTextureSize",
"pWidth",
"=",
"c_uint32",
"(",
")",
"pHeight",
"=",
"c_uint32",
"(",
")",
"result",
"=",
"fn",
"(",
"ulOverlayHandle",
",",
"byref",
"(",
"pWidth",
")",
",",
"byref",
"(",
"pHeight",
")",
")",
"return",
"result",
",",
"pWidth",
".",
"value",
",",
"pHeight",
".",
"value"
] |
Get the size of the overlay texture
|
[
"Get",
"the",
"size",
"of",
"the",
"overlay",
"texture"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5134-L5141
|
15,702
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.createDashboardOverlay
|
def createDashboardOverlay(self, pchOverlayKey, pchOverlayFriendlyName):
"""Creates a dashboard overlay and returns its handle"""
fn = self.function_table.createDashboardOverlay
pMainHandle = VROverlayHandle_t()
pThumbnailHandle = VROverlayHandle_t()
result = fn(pchOverlayKey, pchOverlayFriendlyName, byref(pMainHandle), byref(pThumbnailHandle))
return result, pMainHandle, pThumbnailHandle
|
python
|
def createDashboardOverlay(self, pchOverlayKey, pchOverlayFriendlyName):
"""Creates a dashboard overlay and returns its handle"""
fn = self.function_table.createDashboardOverlay
pMainHandle = VROverlayHandle_t()
pThumbnailHandle = VROverlayHandle_t()
result = fn(pchOverlayKey, pchOverlayFriendlyName, byref(pMainHandle), byref(pThumbnailHandle))
return result, pMainHandle, pThumbnailHandle
|
[
"def",
"createDashboardOverlay",
"(",
"self",
",",
"pchOverlayKey",
",",
"pchOverlayFriendlyName",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"createDashboardOverlay",
"pMainHandle",
"=",
"VROverlayHandle_t",
"(",
")",
"pThumbnailHandle",
"=",
"VROverlayHandle_t",
"(",
")",
"result",
"=",
"fn",
"(",
"pchOverlayKey",
",",
"pchOverlayFriendlyName",
",",
"byref",
"(",
"pMainHandle",
")",
",",
"byref",
"(",
"pThumbnailHandle",
")",
")",
"return",
"result",
",",
"pMainHandle",
",",
"pThumbnailHandle"
] |
Creates a dashboard overlay and returns its handle
|
[
"Creates",
"a",
"dashboard",
"overlay",
"and",
"returns",
"its",
"handle"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5143-L5150
|
15,703
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.isActiveDashboardOverlay
|
def isActiveDashboardOverlay(self, ulOverlayHandle):
"""returns true if the dashboard is visible and the specified overlay is the active system Overlay"""
fn = self.function_table.isActiveDashboardOverlay
result = fn(ulOverlayHandle)
return result
|
python
|
def isActiveDashboardOverlay(self, ulOverlayHandle):
"""returns true if the dashboard is visible and the specified overlay is the active system Overlay"""
fn = self.function_table.isActiveDashboardOverlay
result = fn(ulOverlayHandle)
return result
|
[
"def",
"isActiveDashboardOverlay",
"(",
"self",
",",
"ulOverlayHandle",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"isActiveDashboardOverlay",
"result",
"=",
"fn",
"(",
"ulOverlayHandle",
")",
"return",
"result"
] |
returns true if the dashboard is visible and the specified overlay is the active system Overlay
|
[
"returns",
"true",
"if",
"the",
"dashboard",
"is",
"visible",
"and",
"the",
"specified",
"overlay",
"is",
"the",
"active",
"system",
"Overlay"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5159-L5164
|
15,704
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.setDashboardOverlaySceneProcess
|
def setDashboardOverlaySceneProcess(self, ulOverlayHandle, unProcessId):
"""Sets the dashboard overlay to only appear when the specified process ID has scene focus"""
fn = self.function_table.setDashboardOverlaySceneProcess
result = fn(ulOverlayHandle, unProcessId)
return result
|
python
|
def setDashboardOverlaySceneProcess(self, ulOverlayHandle, unProcessId):
"""Sets the dashboard overlay to only appear when the specified process ID has scene focus"""
fn = self.function_table.setDashboardOverlaySceneProcess
result = fn(ulOverlayHandle, unProcessId)
return result
|
[
"def",
"setDashboardOverlaySceneProcess",
"(",
"self",
",",
"ulOverlayHandle",
",",
"unProcessId",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"setDashboardOverlaySceneProcess",
"result",
"=",
"fn",
"(",
"ulOverlayHandle",
",",
"unProcessId",
")",
"return",
"result"
] |
Sets the dashboard overlay to only appear when the specified process ID has scene focus
|
[
"Sets",
"the",
"dashboard",
"overlay",
"to",
"only",
"appear",
"when",
"the",
"specified",
"process",
"ID",
"has",
"scene",
"focus"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5166-L5171
|
15,705
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.getDashboardOverlaySceneProcess
|
def getDashboardOverlaySceneProcess(self, ulOverlayHandle):
"""Gets the process ID that this dashboard overlay requires to have scene focus"""
fn = self.function_table.getDashboardOverlaySceneProcess
punProcessId = c_uint32()
result = fn(ulOverlayHandle, byref(punProcessId))
return result, punProcessId.value
|
python
|
def getDashboardOverlaySceneProcess(self, ulOverlayHandle):
"""Gets the process ID that this dashboard overlay requires to have scene focus"""
fn = self.function_table.getDashboardOverlaySceneProcess
punProcessId = c_uint32()
result = fn(ulOverlayHandle, byref(punProcessId))
return result, punProcessId.value
|
[
"def",
"getDashboardOverlaySceneProcess",
"(",
"self",
",",
"ulOverlayHandle",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getDashboardOverlaySceneProcess",
"punProcessId",
"=",
"c_uint32",
"(",
")",
"result",
"=",
"fn",
"(",
"ulOverlayHandle",
",",
"byref",
"(",
"punProcessId",
")",
")",
"return",
"result",
",",
"punProcessId",
".",
"value"
] |
Gets the process ID that this dashboard overlay requires to have scene focus
|
[
"Gets",
"the",
"process",
"ID",
"that",
"this",
"dashboard",
"overlay",
"requires",
"to",
"have",
"scene",
"focus"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5173-L5179
|
15,706
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.showKeyboard
|
def showKeyboard(self, eInputMode, eLineInputMode, pchDescription, unCharMax, pchExistingText, bUseMinimalMode, uUserValue):
"""Show the virtual keyboard to accept input"""
fn = self.function_table.showKeyboard
result = fn(eInputMode, eLineInputMode, pchDescription, unCharMax, pchExistingText, bUseMinimalMode, uUserValue)
return result
|
python
|
def showKeyboard(self, eInputMode, eLineInputMode, pchDescription, unCharMax, pchExistingText, bUseMinimalMode, uUserValue):
"""Show the virtual keyboard to accept input"""
fn = self.function_table.showKeyboard
result = fn(eInputMode, eLineInputMode, pchDescription, unCharMax, pchExistingText, bUseMinimalMode, uUserValue)
return result
|
[
"def",
"showKeyboard",
"(",
"self",
",",
"eInputMode",
",",
"eLineInputMode",
",",
"pchDescription",
",",
"unCharMax",
",",
"pchExistingText",
",",
"bUseMinimalMode",
",",
"uUserValue",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"showKeyboard",
"result",
"=",
"fn",
"(",
"eInputMode",
",",
"eLineInputMode",
",",
"pchDescription",
",",
"unCharMax",
",",
"pchExistingText",
",",
"bUseMinimalMode",
",",
"uUserValue",
")",
"return",
"result"
] |
Show the virtual keyboard to accept input
|
[
"Show",
"the",
"virtual",
"keyboard",
"to",
"accept",
"input"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5194-L5199
|
15,707
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.getKeyboardText
|
def getKeyboardText(self, pchText, cchText):
"""Get the text that was entered into the text input"""
fn = self.function_table.getKeyboardText
result = fn(pchText, cchText)
return result
|
python
|
def getKeyboardText(self, pchText, cchText):
"""Get the text that was entered into the text input"""
fn = self.function_table.getKeyboardText
result = fn(pchText, cchText)
return result
|
[
"def",
"getKeyboardText",
"(",
"self",
",",
"pchText",
",",
"cchText",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getKeyboardText",
"result",
"=",
"fn",
"(",
"pchText",
",",
"cchText",
")",
"return",
"result"
] |
Get the text that was entered into the text input
|
[
"Get",
"the",
"text",
"that",
"was",
"entered",
"into",
"the",
"text",
"input"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5206-L5211
|
15,708
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.setKeyboardTransformAbsolute
|
def setKeyboardTransformAbsolute(self, eTrackingOrigin):
"""Set the position of the keyboard in world space"""
fn = self.function_table.setKeyboardTransformAbsolute
pmatTrackingOriginToKeyboardTransform = HmdMatrix34_t()
fn(eTrackingOrigin, byref(pmatTrackingOriginToKeyboardTransform))
return pmatTrackingOriginToKeyboardTransform
|
python
|
def setKeyboardTransformAbsolute(self, eTrackingOrigin):
"""Set the position of the keyboard in world space"""
fn = self.function_table.setKeyboardTransformAbsolute
pmatTrackingOriginToKeyboardTransform = HmdMatrix34_t()
fn(eTrackingOrigin, byref(pmatTrackingOriginToKeyboardTransform))
return pmatTrackingOriginToKeyboardTransform
|
[
"def",
"setKeyboardTransformAbsolute",
"(",
"self",
",",
"eTrackingOrigin",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"setKeyboardTransformAbsolute",
"pmatTrackingOriginToKeyboardTransform",
"=",
"HmdMatrix34_t",
"(",
")",
"fn",
"(",
"eTrackingOrigin",
",",
"byref",
"(",
"pmatTrackingOriginToKeyboardTransform",
")",
")",
"return",
"pmatTrackingOriginToKeyboardTransform"
] |
Set the position of the keyboard in world space
|
[
"Set",
"the",
"position",
"of",
"the",
"keyboard",
"in",
"world",
"space"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5219-L5225
|
15,709
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVROverlay.showMessageOverlay
|
def showMessageOverlay(self, pchText, pchCaption, pchButton0Text, pchButton1Text, pchButton2Text, pchButton3Text):
"""Show the message overlay. This will block and return you a result."""
fn = self.function_table.showMessageOverlay
result = fn(pchText, pchCaption, pchButton0Text, pchButton1Text, pchButton2Text, pchButton3Text)
return result
|
python
|
def showMessageOverlay(self, pchText, pchCaption, pchButton0Text, pchButton1Text, pchButton2Text, pchButton3Text):
"""Show the message overlay. This will block and return you a result."""
fn = self.function_table.showMessageOverlay
result = fn(pchText, pchCaption, pchButton0Text, pchButton1Text, pchButton2Text, pchButton3Text)
return result
|
[
"def",
"showMessageOverlay",
"(",
"self",
",",
"pchText",
",",
"pchCaption",
",",
"pchButton0Text",
",",
"pchButton1Text",
",",
"pchButton2Text",
",",
"pchButton3Text",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"showMessageOverlay",
"result",
"=",
"fn",
"(",
"pchText",
",",
"pchCaption",
",",
"pchButton0Text",
",",
"pchButton1Text",
",",
"pchButton2Text",
",",
"pchButton3Text",
")",
"return",
"result"
] |
Show the message overlay. This will block and return you a result.
|
[
"Show",
"the",
"message",
"overlay",
".",
"This",
"will",
"block",
"and",
"return",
"you",
"a",
"result",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5250-L5255
|
15,710
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.freeRenderModel
|
def freeRenderModel(self):
"""
Frees a previously returned render model
It is safe to call this on a null ptr.
"""
fn = self.function_table.freeRenderModel
pRenderModel = RenderModel_t()
fn(byref(pRenderModel))
return pRenderModel
|
python
|
def freeRenderModel(self):
"""
Frees a previously returned render model
It is safe to call this on a null ptr.
"""
fn = self.function_table.freeRenderModel
pRenderModel = RenderModel_t()
fn(byref(pRenderModel))
return pRenderModel
|
[
"def",
"freeRenderModel",
"(",
"self",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"freeRenderModel",
"pRenderModel",
"=",
"RenderModel_t",
"(",
")",
"fn",
"(",
"byref",
"(",
"pRenderModel",
")",
")",
"return",
"pRenderModel"
] |
Frees a previously returned render model
It is safe to call this on a null ptr.
|
[
"Frees",
"a",
"previously",
"returned",
"render",
"model",
"It",
"is",
"safe",
"to",
"call",
"this",
"on",
"a",
"null",
"ptr",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5322-L5331
|
15,711
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.loadTexture_Async
|
def loadTexture_Async(self, textureId):
"""Loads and returns a texture for use in the application."""
fn = self.function_table.loadTexture_Async
ppTexture = POINTER(RenderModel_TextureMap_t)()
result = fn(textureId, byref(ppTexture))
return result, ppTexture
|
python
|
def loadTexture_Async(self, textureId):
"""Loads and returns a texture for use in the application."""
fn = self.function_table.loadTexture_Async
ppTexture = POINTER(RenderModel_TextureMap_t)()
result = fn(textureId, byref(ppTexture))
return result, ppTexture
|
[
"def",
"loadTexture_Async",
"(",
"self",
",",
"textureId",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"loadTexture_Async",
"ppTexture",
"=",
"POINTER",
"(",
"RenderModel_TextureMap_t",
")",
"(",
")",
"result",
"=",
"fn",
"(",
"textureId",
",",
"byref",
"(",
"ppTexture",
")",
")",
"return",
"result",
",",
"ppTexture"
] |
Loads and returns a texture for use in the application.
|
[
"Loads",
"and",
"returns",
"a",
"texture",
"for",
"use",
"in",
"the",
"application",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5333-L5339
|
15,712
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.freeTexture
|
def freeTexture(self):
"""
Frees a previously returned texture
It is safe to call this on a null ptr.
"""
fn = self.function_table.freeTexture
pTexture = RenderModel_TextureMap_t()
fn(byref(pTexture))
return pTexture
|
python
|
def freeTexture(self):
"""
Frees a previously returned texture
It is safe to call this on a null ptr.
"""
fn = self.function_table.freeTexture
pTexture = RenderModel_TextureMap_t()
fn(byref(pTexture))
return pTexture
|
[
"def",
"freeTexture",
"(",
"self",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"freeTexture",
"pTexture",
"=",
"RenderModel_TextureMap_t",
"(",
")",
"fn",
"(",
"byref",
"(",
"pTexture",
")",
")",
"return",
"pTexture"
] |
Frees a previously returned texture
It is safe to call this on a null ptr.
|
[
"Frees",
"a",
"previously",
"returned",
"texture",
"It",
"is",
"safe",
"to",
"call",
"this",
"on",
"a",
"null",
"ptr",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5341-L5350
|
15,713
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.loadTextureD3D11_Async
|
def loadTextureD3D11_Async(self, textureId, pD3D11Device):
"""Creates a D3D11 texture and loads data into it."""
fn = self.function_table.loadTextureD3D11_Async
ppD3D11Texture2D = c_void_p()
result = fn(textureId, pD3D11Device, byref(ppD3D11Texture2D))
return result, ppD3D11Texture2D.value
|
python
|
def loadTextureD3D11_Async(self, textureId, pD3D11Device):
"""Creates a D3D11 texture and loads data into it."""
fn = self.function_table.loadTextureD3D11_Async
ppD3D11Texture2D = c_void_p()
result = fn(textureId, pD3D11Device, byref(ppD3D11Texture2D))
return result, ppD3D11Texture2D.value
|
[
"def",
"loadTextureD3D11_Async",
"(",
"self",
",",
"textureId",
",",
"pD3D11Device",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"loadTextureD3D11_Async",
"ppD3D11Texture2D",
"=",
"c_void_p",
"(",
")",
"result",
"=",
"fn",
"(",
"textureId",
",",
"pD3D11Device",
",",
"byref",
"(",
"ppD3D11Texture2D",
")",
")",
"return",
"result",
",",
"ppD3D11Texture2D",
".",
"value"
] |
Creates a D3D11 texture and loads data into it.
|
[
"Creates",
"a",
"D3D11",
"texture",
"and",
"loads",
"data",
"into",
"it",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5352-L5358
|
15,714
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.loadIntoTextureD3D11_Async
|
def loadIntoTextureD3D11_Async(self, textureId, pDstTexture):
"""Helper function to copy the bits into an existing texture."""
fn = self.function_table.loadIntoTextureD3D11_Async
result = fn(textureId, pDstTexture)
return result
|
python
|
def loadIntoTextureD3D11_Async(self, textureId, pDstTexture):
"""Helper function to copy the bits into an existing texture."""
fn = self.function_table.loadIntoTextureD3D11_Async
result = fn(textureId, pDstTexture)
return result
|
[
"def",
"loadIntoTextureD3D11_Async",
"(",
"self",
",",
"textureId",
",",
"pDstTexture",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"loadIntoTextureD3D11_Async",
"result",
"=",
"fn",
"(",
"textureId",
",",
"pDstTexture",
")",
"return",
"result"
] |
Helper function to copy the bits into an existing texture.
|
[
"Helper",
"function",
"to",
"copy",
"the",
"bits",
"into",
"an",
"existing",
"texture",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5360-L5365
|
15,715
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.getRenderModelName
|
def getRenderModelName(self, unRenderModelIndex, pchRenderModelName, unRenderModelNameLen):
"""
Use this to get the names of available render models. Index does not correlate to a tracked device index, but
is only used for iterating over all available render models. If the index is out of range, this function will return 0.
Otherwise, it will return the size of the buffer required for the name.
"""
fn = self.function_table.getRenderModelName
result = fn(unRenderModelIndex, pchRenderModelName, unRenderModelNameLen)
return result
|
python
|
def getRenderModelName(self, unRenderModelIndex, pchRenderModelName, unRenderModelNameLen):
"""
Use this to get the names of available render models. Index does not correlate to a tracked device index, but
is only used for iterating over all available render models. If the index is out of range, this function will return 0.
Otherwise, it will return the size of the buffer required for the name.
"""
fn = self.function_table.getRenderModelName
result = fn(unRenderModelIndex, pchRenderModelName, unRenderModelNameLen)
return result
|
[
"def",
"getRenderModelName",
"(",
"self",
",",
"unRenderModelIndex",
",",
"pchRenderModelName",
",",
"unRenderModelNameLen",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getRenderModelName",
"result",
"=",
"fn",
"(",
"unRenderModelIndex",
",",
"pchRenderModelName",
",",
"unRenderModelNameLen",
")",
"return",
"result"
] |
Use this to get the names of available render models. Index does not correlate to a tracked device index, but
is only used for iterating over all available render models. If the index is out of range, this function will return 0.
Otherwise, it will return the size of the buffer required for the name.
|
[
"Use",
"this",
"to",
"get",
"the",
"names",
"of",
"available",
"render",
"models",
".",
"Index",
"does",
"not",
"correlate",
"to",
"a",
"tracked",
"device",
"index",
"but",
"is",
"only",
"used",
"for",
"iterating",
"over",
"all",
"available",
"render",
"models",
".",
"If",
"the",
"index",
"is",
"out",
"of",
"range",
"this",
"function",
"will",
"return",
"0",
".",
"Otherwise",
"it",
"will",
"return",
"the",
"size",
"of",
"the",
"buffer",
"required",
"for",
"the",
"name",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5373-L5382
|
15,716
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.getComponentName
|
def getComponentName(self, pchRenderModelName, unComponentIndex, pchComponentName, unComponentNameLen):
"""
Use this to get the names of available components. Index does not correlate to a tracked device index, but
is only used for iterating over all available components. If the index is out of range, this function will return 0.
Otherwise, it will return the size of the buffer required for the name.
"""
fn = self.function_table.getComponentName
result = fn(pchRenderModelName, unComponentIndex, pchComponentName, unComponentNameLen)
return result
|
python
|
def getComponentName(self, pchRenderModelName, unComponentIndex, pchComponentName, unComponentNameLen):
"""
Use this to get the names of available components. Index does not correlate to a tracked device index, but
is only used for iterating over all available components. If the index is out of range, this function will return 0.
Otherwise, it will return the size of the buffer required for the name.
"""
fn = self.function_table.getComponentName
result = fn(pchRenderModelName, unComponentIndex, pchComponentName, unComponentNameLen)
return result
|
[
"def",
"getComponentName",
"(",
"self",
",",
"pchRenderModelName",
",",
"unComponentIndex",
",",
"pchComponentName",
",",
"unComponentNameLen",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getComponentName",
"result",
"=",
"fn",
"(",
"pchRenderModelName",
",",
"unComponentIndex",
",",
"pchComponentName",
",",
"unComponentNameLen",
")",
"return",
"result"
] |
Use this to get the names of available components. Index does not correlate to a tracked device index, but
is only used for iterating over all available components. If the index is out of range, this function will return 0.
Otherwise, it will return the size of the buffer required for the name.
|
[
"Use",
"this",
"to",
"get",
"the",
"names",
"of",
"available",
"components",
".",
"Index",
"does",
"not",
"correlate",
"to",
"a",
"tracked",
"device",
"index",
"but",
"is",
"only",
"used",
"for",
"iterating",
"over",
"all",
"available",
"components",
".",
"If",
"the",
"index",
"is",
"out",
"of",
"range",
"this",
"function",
"will",
"return",
"0",
".",
"Otherwise",
"it",
"will",
"return",
"the",
"size",
"of",
"the",
"buffer",
"required",
"for",
"the",
"name",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5406-L5415
|
15,717
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.getComponentState
|
def getComponentState(self, pchRenderModelName, pchComponentName):
"""This version of GetComponentState takes a controller state block instead of an action origin. This function is deprecated. You should use the new input system and GetComponentStateForDevicePath instead."""
fn = self.function_table.getComponentState
pControllerState = VRControllerState_t()
pState = RenderModel_ControllerMode_State_t()
pComponentState = RenderModel_ComponentState_t()
result = fn(pchRenderModelName, pchComponentName, byref(pControllerState), byref(pState), byref(pComponentState))
return result, pControllerState, pState, pComponentState
|
python
|
def getComponentState(self, pchRenderModelName, pchComponentName):
"""This version of GetComponentState takes a controller state block instead of an action origin. This function is deprecated. You should use the new input system and GetComponentStateForDevicePath instead."""
fn = self.function_table.getComponentState
pControllerState = VRControllerState_t()
pState = RenderModel_ControllerMode_State_t()
pComponentState = RenderModel_ComponentState_t()
result = fn(pchRenderModelName, pchComponentName, byref(pControllerState), byref(pState), byref(pComponentState))
return result, pControllerState, pState, pComponentState
|
[
"def",
"getComponentState",
"(",
"self",
",",
"pchRenderModelName",
",",
"pchComponentName",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getComponentState",
"pControllerState",
"=",
"VRControllerState_t",
"(",
")",
"pState",
"=",
"RenderModel_ControllerMode_State_t",
"(",
")",
"pComponentState",
"=",
"RenderModel_ComponentState_t",
"(",
")",
"result",
"=",
"fn",
"(",
"pchRenderModelName",
",",
"pchComponentName",
",",
"byref",
"(",
"pControllerState",
")",
",",
"byref",
"(",
"pState",
")",
",",
"byref",
"(",
"pComponentState",
")",
")",
"return",
"result",
",",
"pControllerState",
",",
"pState",
",",
"pComponentState"
] |
This version of GetComponentState takes a controller state block instead of an action origin. This function is deprecated. You should use the new input system and GetComponentStateForDevicePath instead.
|
[
"This",
"version",
"of",
"GetComponentState",
"takes",
"a",
"controller",
"state",
"block",
"instead",
"of",
"an",
"action",
"origin",
".",
"This",
"function",
"is",
"deprecated",
".",
"You",
"should",
"use",
"the",
"new",
"input",
"system",
"and",
"GetComponentStateForDevicePath",
"instead",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5456-L5464
|
15,718
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.renderModelHasComponent
|
def renderModelHasComponent(self, pchRenderModelName, pchComponentName):
"""Returns true if the render model has a component with the specified name"""
fn = self.function_table.renderModelHasComponent
result = fn(pchRenderModelName, pchComponentName)
return result
|
python
|
def renderModelHasComponent(self, pchRenderModelName, pchComponentName):
"""Returns true if the render model has a component with the specified name"""
fn = self.function_table.renderModelHasComponent
result = fn(pchRenderModelName, pchComponentName)
return result
|
[
"def",
"renderModelHasComponent",
"(",
"self",
",",
"pchRenderModelName",
",",
"pchComponentName",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"renderModelHasComponent",
"result",
"=",
"fn",
"(",
"pchRenderModelName",
",",
"pchComponentName",
")",
"return",
"result"
] |
Returns true if the render model has a component with the specified name
|
[
"Returns",
"true",
"if",
"the",
"render",
"model",
"has",
"a",
"component",
"with",
"the",
"specified",
"name"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5466-L5471
|
15,719
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.getRenderModelThumbnailURL
|
def getRenderModelThumbnailURL(self, pchRenderModelName, pchThumbnailURL, unThumbnailURLLen):
"""Returns the URL of the thumbnail image for this rendermodel"""
fn = self.function_table.getRenderModelThumbnailURL
peError = EVRRenderModelError()
result = fn(pchRenderModelName, pchThumbnailURL, unThumbnailURLLen, byref(peError))
return result, peError
|
python
|
def getRenderModelThumbnailURL(self, pchRenderModelName, pchThumbnailURL, unThumbnailURLLen):
"""Returns the URL of the thumbnail image for this rendermodel"""
fn = self.function_table.getRenderModelThumbnailURL
peError = EVRRenderModelError()
result = fn(pchRenderModelName, pchThumbnailURL, unThumbnailURLLen, byref(peError))
return result, peError
|
[
"def",
"getRenderModelThumbnailURL",
"(",
"self",
",",
"pchRenderModelName",
",",
"pchThumbnailURL",
",",
"unThumbnailURLLen",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getRenderModelThumbnailURL",
"peError",
"=",
"EVRRenderModelError",
"(",
")",
"result",
"=",
"fn",
"(",
"pchRenderModelName",
",",
"pchThumbnailURL",
",",
"unThumbnailURLLen",
",",
"byref",
"(",
"peError",
")",
")",
"return",
"result",
",",
"peError"
] |
Returns the URL of the thumbnail image for this rendermodel
|
[
"Returns",
"the",
"URL",
"of",
"the",
"thumbnail",
"image",
"for",
"this",
"rendermodel"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5473-L5479
|
15,720
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.getRenderModelOriginalPath
|
def getRenderModelOriginalPath(self, pchRenderModelName, pchOriginalPath, unOriginalPathLen):
"""
Provides a render model path that will load the unskinned model if the model name provided has been replace by the user. If the model
hasn't been replaced the path value will still be a valid path to load the model. Pass this to LoadRenderModel_Async, etc. to load the
model.
"""
fn = self.function_table.getRenderModelOriginalPath
peError = EVRRenderModelError()
result = fn(pchRenderModelName, pchOriginalPath, unOriginalPathLen, byref(peError))
return result, peError
|
python
|
def getRenderModelOriginalPath(self, pchRenderModelName, pchOriginalPath, unOriginalPathLen):
"""
Provides a render model path that will load the unskinned model if the model name provided has been replace by the user. If the model
hasn't been replaced the path value will still be a valid path to load the model. Pass this to LoadRenderModel_Async, etc. to load the
model.
"""
fn = self.function_table.getRenderModelOriginalPath
peError = EVRRenderModelError()
result = fn(pchRenderModelName, pchOriginalPath, unOriginalPathLen, byref(peError))
return result, peError
|
[
"def",
"getRenderModelOriginalPath",
"(",
"self",
",",
"pchRenderModelName",
",",
"pchOriginalPath",
",",
"unOriginalPathLen",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getRenderModelOriginalPath",
"peError",
"=",
"EVRRenderModelError",
"(",
")",
"result",
"=",
"fn",
"(",
"pchRenderModelName",
",",
"pchOriginalPath",
",",
"unOriginalPathLen",
",",
"byref",
"(",
"peError",
")",
")",
"return",
"result",
",",
"peError"
] |
Provides a render model path that will load the unskinned model if the model name provided has been replace by the user. If the model
hasn't been replaced the path value will still be a valid path to load the model. Pass this to LoadRenderModel_Async, etc. to load the
model.
|
[
"Provides",
"a",
"render",
"model",
"path",
"that",
"will",
"load",
"the",
"unskinned",
"model",
"if",
"the",
"model",
"name",
"provided",
"has",
"been",
"replace",
"by",
"the",
"user",
".",
"If",
"the",
"model",
"hasn",
"t",
"been",
"replaced",
"the",
"path",
"value",
"will",
"still",
"be",
"a",
"valid",
"path",
"to",
"load",
"the",
"model",
".",
"Pass",
"this",
"to",
"LoadRenderModel_Async",
"etc",
".",
"to",
"load",
"the",
"model",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5481-L5491
|
15,721
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRRenderModels.getRenderModelErrorNameFromEnum
|
def getRenderModelErrorNameFromEnum(self, error):
"""Returns a string for a render model error"""
fn = self.function_table.getRenderModelErrorNameFromEnum
result = fn(error)
return result
|
python
|
def getRenderModelErrorNameFromEnum(self, error):
"""Returns a string for a render model error"""
fn = self.function_table.getRenderModelErrorNameFromEnum
result = fn(error)
return result
|
[
"def",
"getRenderModelErrorNameFromEnum",
"(",
"self",
",",
"error",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getRenderModelErrorNameFromEnum",
"result",
"=",
"fn",
"(",
"error",
")",
"return",
"result"
] |
Returns a string for a render model error
|
[
"Returns",
"a",
"string",
"for",
"a",
"render",
"model",
"error"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5493-L5498
|
15,722
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRNotifications.removeNotification
|
def removeNotification(self, notificationId):
"""Destroy a notification, hiding it first if it currently shown to the user."""
fn = self.function_table.removeNotification
result = fn(notificationId)
return result
|
python
|
def removeNotification(self, notificationId):
"""Destroy a notification, hiding it first if it currently shown to the user."""
fn = self.function_table.removeNotification
result = fn(notificationId)
return result
|
[
"def",
"removeNotification",
"(",
"self",
",",
"notificationId",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"removeNotification",
"result",
"=",
"fn",
"(",
"notificationId",
")",
"return",
"result"
] |
Destroy a notification, hiding it first if it currently shown to the user.
|
[
"Destroy",
"a",
"notification",
"hiding",
"it",
"first",
"if",
"it",
"currently",
"shown",
"to",
"the",
"user",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5541-L5546
|
15,723
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRScreenshots.hookScreenshot
|
def hookScreenshot(self, numTypes):
"""
Called by the running VR application to indicate that it
wishes to be in charge of screenshots. If the
application does not call this, the Compositor will only
support VRScreenshotType_Stereo screenshots that will be
captured without notification to the running app.
Once hooked your application will receive a
VREvent_RequestScreenshot event when the user presses the
buttons to take a screenshot.
"""
fn = self.function_table.hookScreenshot
pSupportedTypes = EVRScreenshotType()
result = fn(byref(pSupportedTypes), numTypes)
return result, pSupportedTypes
|
python
|
def hookScreenshot(self, numTypes):
"""
Called by the running VR application to indicate that it
wishes to be in charge of screenshots. If the
application does not call this, the Compositor will only
support VRScreenshotType_Stereo screenshots that will be
captured without notification to the running app.
Once hooked your application will receive a
VREvent_RequestScreenshot event when the user presses the
buttons to take a screenshot.
"""
fn = self.function_table.hookScreenshot
pSupportedTypes = EVRScreenshotType()
result = fn(byref(pSupportedTypes), numTypes)
return result, pSupportedTypes
|
[
"def",
"hookScreenshot",
"(",
"self",
",",
"numTypes",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"hookScreenshot",
"pSupportedTypes",
"=",
"EVRScreenshotType",
"(",
")",
"result",
"=",
"fn",
"(",
"byref",
"(",
"pSupportedTypes",
")",
",",
"numTypes",
")",
"return",
"result",
",",
"pSupportedTypes"
] |
Called by the running VR application to indicate that it
wishes to be in charge of screenshots. If the
application does not call this, the Compositor will only
support VRScreenshotType_Stereo screenshots that will be
captured without notification to the running app.
Once hooked your application will receive a
VREvent_RequestScreenshot event when the user presses the
buttons to take a screenshot.
|
[
"Called",
"by",
"the",
"running",
"VR",
"application",
"to",
"indicate",
"that",
"it",
"wishes",
"to",
"be",
"in",
"charge",
"of",
"screenshots",
".",
"If",
"the",
"application",
"does",
"not",
"call",
"this",
"the",
"Compositor",
"will",
"only",
"support",
"VRScreenshotType_Stereo",
"screenshots",
"that",
"will",
"be",
"captured",
"without",
"notification",
"to",
"the",
"running",
"app",
".",
"Once",
"hooked",
"your",
"application",
"will",
"receive",
"a",
"VREvent_RequestScreenshot",
"event",
"when",
"the",
"user",
"presses",
"the",
"buttons",
"to",
"take",
"a",
"screenshot",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5727-L5742
|
15,724
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRScreenshots.getScreenshotPropertyType
|
def getScreenshotPropertyType(self, screenshotHandle):
"""
When your application receives a
VREvent_RequestScreenshot event, call these functions to get
the details of the screenshot request.
"""
fn = self.function_table.getScreenshotPropertyType
pError = EVRScreenshotError()
result = fn(screenshotHandle, byref(pError))
return result, pError
|
python
|
def getScreenshotPropertyType(self, screenshotHandle):
"""
When your application receives a
VREvent_RequestScreenshot event, call these functions to get
the details of the screenshot request.
"""
fn = self.function_table.getScreenshotPropertyType
pError = EVRScreenshotError()
result = fn(screenshotHandle, byref(pError))
return result, pError
|
[
"def",
"getScreenshotPropertyType",
"(",
"self",
",",
"screenshotHandle",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getScreenshotPropertyType",
"pError",
"=",
"EVRScreenshotError",
"(",
")",
"result",
"=",
"fn",
"(",
"screenshotHandle",
",",
"byref",
"(",
"pError",
")",
")",
"return",
"result",
",",
"pError"
] |
When your application receives a
VREvent_RequestScreenshot event, call these functions to get
the details of the screenshot request.
|
[
"When",
"your",
"application",
"receives",
"a",
"VREvent_RequestScreenshot",
"event",
"call",
"these",
"functions",
"to",
"get",
"the",
"details",
"of",
"the",
"screenshot",
"request",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5744-L5754
|
15,725
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRScreenshots.updateScreenshotProgress
|
def updateScreenshotProgress(self, screenshotHandle, flProgress):
"""
Call this if the application is taking the screen shot
will take more than a few ms processing. This will result
in an overlay being presented that shows a completion
bar.
"""
fn = self.function_table.updateScreenshotProgress
result = fn(screenshotHandle, flProgress)
return result
|
python
|
def updateScreenshotProgress(self, screenshotHandle, flProgress):
"""
Call this if the application is taking the screen shot
will take more than a few ms processing. This will result
in an overlay being presented that shows a completion
bar.
"""
fn = self.function_table.updateScreenshotProgress
result = fn(screenshotHandle, flProgress)
return result
|
[
"def",
"updateScreenshotProgress",
"(",
"self",
",",
"screenshotHandle",
",",
"flProgress",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"updateScreenshotProgress",
"result",
"=",
"fn",
"(",
"screenshotHandle",
",",
"flProgress",
")",
"return",
"result"
] |
Call this if the application is taking the screen shot
will take more than a few ms processing. This will result
in an overlay being presented that shows a completion
bar.
|
[
"Call",
"this",
"if",
"the",
"application",
"is",
"taking",
"the",
"screen",
"shot",
"will",
"take",
"more",
"than",
"a",
"few",
"ms",
"processing",
".",
"This",
"will",
"result",
"in",
"an",
"overlay",
"being",
"presented",
"that",
"shows",
"a",
"completion",
"bar",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5768-L5778
|
15,726
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRScreenshots.takeStereoScreenshot
|
def takeStereoScreenshot(self, pchPreviewFilename, pchVRFilename):
"""
Tells the compositor to take an internal screenshot of
type VRScreenshotType_Stereo. It will take the current
submitted scene textures of the running application and
write them into the preview image and a side-by-side file
for the VR image.
This is similar to request screenshot, but doesn't ever
talk to the application, just takes the shot and submits.
"""
fn = self.function_table.takeStereoScreenshot
pOutScreenshotHandle = ScreenshotHandle_t()
result = fn(byref(pOutScreenshotHandle), pchPreviewFilename, pchVRFilename)
return result, pOutScreenshotHandle
|
python
|
def takeStereoScreenshot(self, pchPreviewFilename, pchVRFilename):
"""
Tells the compositor to take an internal screenshot of
type VRScreenshotType_Stereo. It will take the current
submitted scene textures of the running application and
write them into the preview image and a side-by-side file
for the VR image.
This is similar to request screenshot, but doesn't ever
talk to the application, just takes the shot and submits.
"""
fn = self.function_table.takeStereoScreenshot
pOutScreenshotHandle = ScreenshotHandle_t()
result = fn(byref(pOutScreenshotHandle), pchPreviewFilename, pchVRFilename)
return result, pOutScreenshotHandle
|
[
"def",
"takeStereoScreenshot",
"(",
"self",
",",
"pchPreviewFilename",
",",
"pchVRFilename",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"takeStereoScreenshot",
"pOutScreenshotHandle",
"=",
"ScreenshotHandle_t",
"(",
")",
"result",
"=",
"fn",
"(",
"byref",
"(",
"pOutScreenshotHandle",
")",
",",
"pchPreviewFilename",
",",
"pchVRFilename",
")",
"return",
"result",
",",
"pOutScreenshotHandle"
] |
Tells the compositor to take an internal screenshot of
type VRScreenshotType_Stereo. It will take the current
submitted scene textures of the running application and
write them into the preview image and a side-by-side file
for the VR image.
This is similar to request screenshot, but doesn't ever
talk to the application, just takes the shot and submits.
|
[
"Tells",
"the",
"compositor",
"to",
"take",
"an",
"internal",
"screenshot",
"of",
"type",
"VRScreenshotType_Stereo",
".",
"It",
"will",
"take",
"the",
"current",
"submitted",
"scene",
"textures",
"of",
"the",
"running",
"application",
"and",
"write",
"them",
"into",
"the",
"preview",
"image",
"and",
"a",
"side",
"-",
"by",
"-",
"side",
"file",
"for",
"the",
"VR",
"image",
".",
"This",
"is",
"similar",
"to",
"request",
"screenshot",
"but",
"doesn",
"t",
"ever",
"talk",
"to",
"the",
"application",
"just",
"takes",
"the",
"shot",
"and",
"submits",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5780-L5794
|
15,727
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRResources.loadSharedResource
|
def loadSharedResource(self, pchResourceName, pchBuffer, unBufferLen):
"""
Loads the specified resource into the provided buffer if large enough.
Returns the size in bytes of the buffer required to hold the specified resource.
"""
fn = self.function_table.loadSharedResource
result = fn(pchResourceName, pchBuffer, unBufferLen)
return result
|
python
|
def loadSharedResource(self, pchResourceName, pchBuffer, unBufferLen):
"""
Loads the specified resource into the provided buffer if large enough.
Returns the size in bytes of the buffer required to hold the specified resource.
"""
fn = self.function_table.loadSharedResource
result = fn(pchResourceName, pchBuffer, unBufferLen)
return result
|
[
"def",
"loadSharedResource",
"(",
"self",
",",
"pchResourceName",
",",
"pchBuffer",
",",
"unBufferLen",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"loadSharedResource",
"result",
"=",
"fn",
"(",
"pchResourceName",
",",
"pchBuffer",
",",
"unBufferLen",
")",
"return",
"result"
] |
Loads the specified resource into the provided buffer if large enough.
Returns the size in bytes of the buffer required to hold the specified resource.
|
[
"Loads",
"the",
"specified",
"resource",
"into",
"the",
"provided",
"buffer",
"if",
"large",
"enough",
".",
"Returns",
"the",
"size",
"in",
"bytes",
"of",
"the",
"buffer",
"required",
"to",
"hold",
"the",
"specified",
"resource",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5837-L5845
|
15,728
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRResources.getResourceFullPath
|
def getResourceFullPath(self, pchResourceName, pchResourceTypeDirectory, pchPathBuffer, unBufferLen):
"""
Provides the full path to the specified resource. Resource names can include named directories for
drivers and other things, and this resolves all of those and returns the actual physical path.
pchResourceTypeDirectory is the subdirectory of resources to look in.
"""
fn = self.function_table.getResourceFullPath
result = fn(pchResourceName, pchResourceTypeDirectory, pchPathBuffer, unBufferLen)
return result
|
python
|
def getResourceFullPath(self, pchResourceName, pchResourceTypeDirectory, pchPathBuffer, unBufferLen):
"""
Provides the full path to the specified resource. Resource names can include named directories for
drivers and other things, and this resolves all of those and returns the actual physical path.
pchResourceTypeDirectory is the subdirectory of resources to look in.
"""
fn = self.function_table.getResourceFullPath
result = fn(pchResourceName, pchResourceTypeDirectory, pchPathBuffer, unBufferLen)
return result
|
[
"def",
"getResourceFullPath",
"(",
"self",
",",
"pchResourceName",
",",
"pchResourceTypeDirectory",
",",
"pchPathBuffer",
",",
"unBufferLen",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getResourceFullPath",
"result",
"=",
"fn",
"(",
"pchResourceName",
",",
"pchResourceTypeDirectory",
",",
"pchPathBuffer",
",",
"unBufferLen",
")",
"return",
"result"
] |
Provides the full path to the specified resource. Resource names can include named directories for
drivers and other things, and this resolves all of those and returns the actual physical path.
pchResourceTypeDirectory is the subdirectory of resources to look in.
|
[
"Provides",
"the",
"full",
"path",
"to",
"the",
"specified",
"resource",
".",
"Resource",
"names",
"can",
"include",
"named",
"directories",
"for",
"drivers",
"and",
"other",
"things",
"and",
"this",
"resolves",
"all",
"of",
"those",
"and",
"returns",
"the",
"actual",
"physical",
"path",
".",
"pchResourceTypeDirectory",
"is",
"the",
"subdirectory",
"of",
"resources",
"to",
"look",
"in",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5847-L5856
|
15,729
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRDriverManager.getDriverName
|
def getDriverName(self, nDriver, pchValue, unBufferSize):
"""Returns the length of the number of bytes necessary to hold this string including the trailing null."""
fn = self.function_table.getDriverName
result = fn(nDriver, pchValue, unBufferSize)
return result
|
python
|
def getDriverName(self, nDriver, pchValue, unBufferSize):
"""Returns the length of the number of bytes necessary to hold this string including the trailing null."""
fn = self.function_table.getDriverName
result = fn(nDriver, pchValue, unBufferSize)
return result
|
[
"def",
"getDriverName",
"(",
"self",
",",
"nDriver",
",",
"pchValue",
",",
"unBufferSize",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getDriverName",
"result",
"=",
"fn",
"(",
"nDriver",
",",
"pchValue",
",",
"unBufferSize",
")",
"return",
"result"
] |
Returns the length of the number of bytes necessary to hold this string including the trailing null.
|
[
"Returns",
"the",
"length",
"of",
"the",
"number",
"of",
"bytes",
"necessary",
"to",
"hold",
"this",
"string",
"including",
"the",
"trailing",
"null",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5886-L5891
|
15,730
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getActionSetHandle
|
def getActionSetHandle(self, pchActionSetName):
"""Returns a handle for an action set. This handle is used for all performance-sensitive calls."""
fn = self.function_table.getActionSetHandle
pHandle = VRActionSetHandle_t()
result = fn(pchActionSetName, byref(pHandle))
return result, pHandle
|
python
|
def getActionSetHandle(self, pchActionSetName):
"""Returns a handle for an action set. This handle is used for all performance-sensitive calls."""
fn = self.function_table.getActionSetHandle
pHandle = VRActionSetHandle_t()
result = fn(pchActionSetName, byref(pHandle))
return result, pHandle
|
[
"def",
"getActionSetHandle",
"(",
"self",
",",
"pchActionSetName",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getActionSetHandle",
"pHandle",
"=",
"VRActionSetHandle_t",
"(",
")",
"result",
"=",
"fn",
"(",
"pchActionSetName",
",",
"byref",
"(",
"pHandle",
")",
")",
"return",
"result",
",",
"pHandle"
] |
Returns a handle for an action set. This handle is used for all performance-sensitive calls.
|
[
"Returns",
"a",
"handle",
"for",
"an",
"action",
"set",
".",
"This",
"handle",
"is",
"used",
"for",
"all",
"performance",
"-",
"sensitive",
"calls",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5955-L5961
|
15,731
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getActionHandle
|
def getActionHandle(self, pchActionName):
"""Returns a handle for an action. This handle is used for all performance-sensitive calls."""
fn = self.function_table.getActionHandle
pHandle = VRActionHandle_t()
result = fn(pchActionName, byref(pHandle))
return result, pHandle
|
python
|
def getActionHandle(self, pchActionName):
"""Returns a handle for an action. This handle is used for all performance-sensitive calls."""
fn = self.function_table.getActionHandle
pHandle = VRActionHandle_t()
result = fn(pchActionName, byref(pHandle))
return result, pHandle
|
[
"def",
"getActionHandle",
"(",
"self",
",",
"pchActionName",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getActionHandle",
"pHandle",
"=",
"VRActionHandle_t",
"(",
")",
"result",
"=",
"fn",
"(",
"pchActionName",
",",
"byref",
"(",
"pHandle",
")",
")",
"return",
"result",
",",
"pHandle"
] |
Returns a handle for an action. This handle is used for all performance-sensitive calls.
|
[
"Returns",
"a",
"handle",
"for",
"an",
"action",
".",
"This",
"handle",
"is",
"used",
"for",
"all",
"performance",
"-",
"sensitive",
"calls",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5963-L5969
|
15,732
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getDigitalActionData
|
def getDigitalActionData(self, action, unActionDataSize, ulRestrictToDevice):
"""
Reads the state of a digital action given its handle. This will return VRInputError_WrongType if the type of
action is something other than digital
"""
fn = self.function_table.getDigitalActionData
pActionData = InputDigitalActionData_t()
result = fn(action, byref(pActionData), unActionDataSize, ulRestrictToDevice)
return result, pActionData
|
python
|
def getDigitalActionData(self, action, unActionDataSize, ulRestrictToDevice):
"""
Reads the state of a digital action given its handle. This will return VRInputError_WrongType if the type of
action is something other than digital
"""
fn = self.function_table.getDigitalActionData
pActionData = InputDigitalActionData_t()
result = fn(action, byref(pActionData), unActionDataSize, ulRestrictToDevice)
return result, pActionData
|
[
"def",
"getDigitalActionData",
"(",
"self",
",",
"action",
",",
"unActionDataSize",
",",
"ulRestrictToDevice",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getDigitalActionData",
"pActionData",
"=",
"InputDigitalActionData_t",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"byref",
"(",
"pActionData",
")",
",",
"unActionDataSize",
",",
"ulRestrictToDevice",
")",
"return",
"result",
",",
"pActionData"
] |
Reads the state of a digital action given its handle. This will return VRInputError_WrongType if the type of
action is something other than digital
|
[
"Reads",
"the",
"state",
"of",
"a",
"digital",
"action",
"given",
"its",
"handle",
".",
"This",
"will",
"return",
"VRInputError_WrongType",
"if",
"the",
"type",
"of",
"action",
"is",
"something",
"other",
"than",
"digital"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5990-L5999
|
15,733
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getAnalogActionData
|
def getAnalogActionData(self, action, unActionDataSize, ulRestrictToDevice):
"""
Reads the state of an analog action given its handle. This will return VRInputError_WrongType if the type of
action is something other than analog
"""
fn = self.function_table.getAnalogActionData
pActionData = InputAnalogActionData_t()
result = fn(action, byref(pActionData), unActionDataSize, ulRestrictToDevice)
return result, pActionData
|
python
|
def getAnalogActionData(self, action, unActionDataSize, ulRestrictToDevice):
"""
Reads the state of an analog action given its handle. This will return VRInputError_WrongType if the type of
action is something other than analog
"""
fn = self.function_table.getAnalogActionData
pActionData = InputAnalogActionData_t()
result = fn(action, byref(pActionData), unActionDataSize, ulRestrictToDevice)
return result, pActionData
|
[
"def",
"getAnalogActionData",
"(",
"self",
",",
"action",
",",
"unActionDataSize",
",",
"ulRestrictToDevice",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getAnalogActionData",
"pActionData",
"=",
"InputAnalogActionData_t",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"byref",
"(",
"pActionData",
")",
",",
"unActionDataSize",
",",
"ulRestrictToDevice",
")",
"return",
"result",
",",
"pActionData"
] |
Reads the state of an analog action given its handle. This will return VRInputError_WrongType if the type of
action is something other than analog
|
[
"Reads",
"the",
"state",
"of",
"an",
"analog",
"action",
"given",
"its",
"handle",
".",
"This",
"will",
"return",
"VRInputError_WrongType",
"if",
"the",
"type",
"of",
"action",
"is",
"something",
"other",
"than",
"analog"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6001-L6010
|
15,734
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getPoseActionData
|
def getPoseActionData(self, action, eOrigin, fPredictedSecondsFromNow, unActionDataSize, ulRestrictToDevice):
"""Reads the state of a pose action given its handle."""
fn = self.function_table.getPoseActionData
pActionData = InputPoseActionData_t()
result = fn(action, eOrigin, fPredictedSecondsFromNow, byref(pActionData), unActionDataSize, ulRestrictToDevice)
return result, pActionData
|
python
|
def getPoseActionData(self, action, eOrigin, fPredictedSecondsFromNow, unActionDataSize, ulRestrictToDevice):
"""Reads the state of a pose action given its handle."""
fn = self.function_table.getPoseActionData
pActionData = InputPoseActionData_t()
result = fn(action, eOrigin, fPredictedSecondsFromNow, byref(pActionData), unActionDataSize, ulRestrictToDevice)
return result, pActionData
|
[
"def",
"getPoseActionData",
"(",
"self",
",",
"action",
",",
"eOrigin",
",",
"fPredictedSecondsFromNow",
",",
"unActionDataSize",
",",
"ulRestrictToDevice",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getPoseActionData",
"pActionData",
"=",
"InputPoseActionData_t",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"eOrigin",
",",
"fPredictedSecondsFromNow",
",",
"byref",
"(",
"pActionData",
")",
",",
"unActionDataSize",
",",
"ulRestrictToDevice",
")",
"return",
"result",
",",
"pActionData"
] |
Reads the state of a pose action given its handle.
|
[
"Reads",
"the",
"state",
"of",
"a",
"pose",
"action",
"given",
"its",
"handle",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6012-L6018
|
15,735
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getSkeletalActionData
|
def getSkeletalActionData(self, action, unActionDataSize):
"""Reads the state of a skeletal action given its handle."""
fn = self.function_table.getSkeletalActionData
pActionData = InputSkeletalActionData_t()
result = fn(action, byref(pActionData), unActionDataSize)
return result, pActionData
|
python
|
def getSkeletalActionData(self, action, unActionDataSize):
"""Reads the state of a skeletal action given its handle."""
fn = self.function_table.getSkeletalActionData
pActionData = InputSkeletalActionData_t()
result = fn(action, byref(pActionData), unActionDataSize)
return result, pActionData
|
[
"def",
"getSkeletalActionData",
"(",
"self",
",",
"action",
",",
"unActionDataSize",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getSkeletalActionData",
"pActionData",
"=",
"InputSkeletalActionData_t",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"byref",
"(",
"pActionData",
")",
",",
"unActionDataSize",
")",
"return",
"result",
",",
"pActionData"
] |
Reads the state of a skeletal action given its handle.
|
[
"Reads",
"the",
"state",
"of",
"a",
"skeletal",
"action",
"given",
"its",
"handle",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6020-L6026
|
15,736
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getBoneCount
|
def getBoneCount(self, action):
"""Reads the number of bones in skeleton associated with the given action"""
fn = self.function_table.getBoneCount
pBoneCount = c_uint32()
result = fn(action, byref(pBoneCount))
return result, pBoneCount.value
|
python
|
def getBoneCount(self, action):
"""Reads the number of bones in skeleton associated with the given action"""
fn = self.function_table.getBoneCount
pBoneCount = c_uint32()
result = fn(action, byref(pBoneCount))
return result, pBoneCount.value
|
[
"def",
"getBoneCount",
"(",
"self",
",",
"action",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getBoneCount",
"pBoneCount",
"=",
"c_uint32",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"byref",
"(",
"pBoneCount",
")",
")",
"return",
"result",
",",
"pBoneCount",
".",
"value"
] |
Reads the number of bones in skeleton associated with the given action
|
[
"Reads",
"the",
"number",
"of",
"bones",
"in",
"skeleton",
"associated",
"with",
"the",
"given",
"action"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6028-L6034
|
15,737
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getBoneHierarchy
|
def getBoneHierarchy(self, action, unIndexArayCount):
"""Fills the given array with the index of each bone's parent in the skeleton associated with the given action"""
fn = self.function_table.getBoneHierarchy
pParentIndices = BoneIndex_t()
result = fn(action, byref(pParentIndices), unIndexArayCount)
return result, pParentIndices
|
python
|
def getBoneHierarchy(self, action, unIndexArayCount):
"""Fills the given array with the index of each bone's parent in the skeleton associated with the given action"""
fn = self.function_table.getBoneHierarchy
pParentIndices = BoneIndex_t()
result = fn(action, byref(pParentIndices), unIndexArayCount)
return result, pParentIndices
|
[
"def",
"getBoneHierarchy",
"(",
"self",
",",
"action",
",",
"unIndexArayCount",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getBoneHierarchy",
"pParentIndices",
"=",
"BoneIndex_t",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"byref",
"(",
"pParentIndices",
")",
",",
"unIndexArayCount",
")",
"return",
"result",
",",
"pParentIndices"
] |
Fills the given array with the index of each bone's parent in the skeleton associated with the given action
|
[
"Fills",
"the",
"given",
"array",
"with",
"the",
"index",
"of",
"each",
"bone",
"s",
"parent",
"in",
"the",
"skeleton",
"associated",
"with",
"the",
"given",
"action"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6036-L6042
|
15,738
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getBoneName
|
def getBoneName(self, action, nBoneIndex, pchBoneName, unNameBufferSize):
"""Fills the given buffer with the name of the bone at the given index in the skeleton associated with the given action"""
fn = self.function_table.getBoneName
result = fn(action, nBoneIndex, pchBoneName, unNameBufferSize)
return result
|
python
|
def getBoneName(self, action, nBoneIndex, pchBoneName, unNameBufferSize):
"""Fills the given buffer with the name of the bone at the given index in the skeleton associated with the given action"""
fn = self.function_table.getBoneName
result = fn(action, nBoneIndex, pchBoneName, unNameBufferSize)
return result
|
[
"def",
"getBoneName",
"(",
"self",
",",
"action",
",",
"nBoneIndex",
",",
"pchBoneName",
",",
"unNameBufferSize",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getBoneName",
"result",
"=",
"fn",
"(",
"action",
",",
"nBoneIndex",
",",
"pchBoneName",
",",
"unNameBufferSize",
")",
"return",
"result"
] |
Fills the given buffer with the name of the bone at the given index in the skeleton associated with the given action
|
[
"Fills",
"the",
"given",
"buffer",
"with",
"the",
"name",
"of",
"the",
"bone",
"at",
"the",
"given",
"index",
"in",
"the",
"skeleton",
"associated",
"with",
"the",
"given",
"action"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6044-L6049
|
15,739
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getSkeletalReferenceTransforms
|
def getSkeletalReferenceTransforms(self, action, eTransformSpace, eReferencePose, unTransformArrayCount):
"""Fills the given buffer with the transforms for a specific static skeletal reference pose"""
fn = self.function_table.getSkeletalReferenceTransforms
pTransformArray = VRBoneTransform_t()
result = fn(action, eTransformSpace, eReferencePose, byref(pTransformArray), unTransformArrayCount)
return result, pTransformArray
|
python
|
def getSkeletalReferenceTransforms(self, action, eTransformSpace, eReferencePose, unTransformArrayCount):
"""Fills the given buffer with the transforms for a specific static skeletal reference pose"""
fn = self.function_table.getSkeletalReferenceTransforms
pTransformArray = VRBoneTransform_t()
result = fn(action, eTransformSpace, eReferencePose, byref(pTransformArray), unTransformArrayCount)
return result, pTransformArray
|
[
"def",
"getSkeletalReferenceTransforms",
"(",
"self",
",",
"action",
",",
"eTransformSpace",
",",
"eReferencePose",
",",
"unTransformArrayCount",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getSkeletalReferenceTransforms",
"pTransformArray",
"=",
"VRBoneTransform_t",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"eTransformSpace",
",",
"eReferencePose",
",",
"byref",
"(",
"pTransformArray",
")",
",",
"unTransformArrayCount",
")",
"return",
"result",
",",
"pTransformArray"
] |
Fills the given buffer with the transforms for a specific static skeletal reference pose
|
[
"Fills",
"the",
"given",
"buffer",
"with",
"the",
"transforms",
"for",
"a",
"specific",
"static",
"skeletal",
"reference",
"pose"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6051-L6057
|
15,740
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getSkeletalTrackingLevel
|
def getSkeletalTrackingLevel(self, action):
"""Reads the level of accuracy to which the controller is able to track the user to recreate a skeletal pose"""
fn = self.function_table.getSkeletalTrackingLevel
pSkeletalTrackingLevel = EVRSkeletalTrackingLevel()
result = fn(action, byref(pSkeletalTrackingLevel))
return result, pSkeletalTrackingLevel
|
python
|
def getSkeletalTrackingLevel(self, action):
"""Reads the level of accuracy to which the controller is able to track the user to recreate a skeletal pose"""
fn = self.function_table.getSkeletalTrackingLevel
pSkeletalTrackingLevel = EVRSkeletalTrackingLevel()
result = fn(action, byref(pSkeletalTrackingLevel))
return result, pSkeletalTrackingLevel
|
[
"def",
"getSkeletalTrackingLevel",
"(",
"self",
",",
"action",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getSkeletalTrackingLevel",
"pSkeletalTrackingLevel",
"=",
"EVRSkeletalTrackingLevel",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"byref",
"(",
"pSkeletalTrackingLevel",
")",
")",
"return",
"result",
",",
"pSkeletalTrackingLevel"
] |
Reads the level of accuracy to which the controller is able to track the user to recreate a skeletal pose
|
[
"Reads",
"the",
"level",
"of",
"accuracy",
"to",
"which",
"the",
"controller",
"is",
"able",
"to",
"track",
"the",
"user",
"to",
"recreate",
"a",
"skeletal",
"pose"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6059-L6065
|
15,741
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getSkeletalBoneData
|
def getSkeletalBoneData(self, action, eTransformSpace, eMotionRange, unTransformArrayCount):
"""Reads the state of the skeletal bone data associated with this action and copies it into the given buffer."""
fn = self.function_table.getSkeletalBoneData
pTransformArray = VRBoneTransform_t()
result = fn(action, eTransformSpace, eMotionRange, byref(pTransformArray), unTransformArrayCount)
return result, pTransformArray
|
python
|
def getSkeletalBoneData(self, action, eTransformSpace, eMotionRange, unTransformArrayCount):
"""Reads the state of the skeletal bone data associated with this action and copies it into the given buffer."""
fn = self.function_table.getSkeletalBoneData
pTransformArray = VRBoneTransform_t()
result = fn(action, eTransformSpace, eMotionRange, byref(pTransformArray), unTransformArrayCount)
return result, pTransformArray
|
[
"def",
"getSkeletalBoneData",
"(",
"self",
",",
"action",
",",
"eTransformSpace",
",",
"eMotionRange",
",",
"unTransformArrayCount",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getSkeletalBoneData",
"pTransformArray",
"=",
"VRBoneTransform_t",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"eTransformSpace",
",",
"eMotionRange",
",",
"byref",
"(",
"pTransformArray",
")",
",",
"unTransformArrayCount",
")",
"return",
"result",
",",
"pTransformArray"
] |
Reads the state of the skeletal bone data associated with this action and copies it into the given buffer.
|
[
"Reads",
"the",
"state",
"of",
"the",
"skeletal",
"bone",
"data",
"associated",
"with",
"this",
"action",
"and",
"copies",
"it",
"into",
"the",
"given",
"buffer",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6067-L6073
|
15,742
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getSkeletalSummaryData
|
def getSkeletalSummaryData(self, action):
"""Reads summary information about the current pose of the skeleton associated with the given action."""
fn = self.function_table.getSkeletalSummaryData
pSkeletalSummaryData = VRSkeletalSummaryData_t()
result = fn(action, byref(pSkeletalSummaryData))
return result, pSkeletalSummaryData
|
python
|
def getSkeletalSummaryData(self, action):
"""Reads summary information about the current pose of the skeleton associated with the given action."""
fn = self.function_table.getSkeletalSummaryData
pSkeletalSummaryData = VRSkeletalSummaryData_t()
result = fn(action, byref(pSkeletalSummaryData))
return result, pSkeletalSummaryData
|
[
"def",
"getSkeletalSummaryData",
"(",
"self",
",",
"action",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getSkeletalSummaryData",
"pSkeletalSummaryData",
"=",
"VRSkeletalSummaryData_t",
"(",
")",
"result",
"=",
"fn",
"(",
"action",
",",
"byref",
"(",
"pSkeletalSummaryData",
")",
")",
"return",
"result",
",",
"pSkeletalSummaryData"
] |
Reads summary information about the current pose of the skeleton associated with the given action.
|
[
"Reads",
"summary",
"information",
"about",
"the",
"current",
"pose",
"of",
"the",
"skeleton",
"associated",
"with",
"the",
"given",
"action",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6075-L6081
|
15,743
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.decompressSkeletalBoneData
|
def decompressSkeletalBoneData(self, pvCompressedBuffer, unCompressedBufferSize, eTransformSpace, unTransformArrayCount):
"""Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array."""
fn = self.function_table.decompressSkeletalBoneData
pTransformArray = VRBoneTransform_t()
result = fn(pvCompressedBuffer, unCompressedBufferSize, eTransformSpace, byref(pTransformArray), unTransformArrayCount)
return result, pTransformArray
|
python
|
def decompressSkeletalBoneData(self, pvCompressedBuffer, unCompressedBufferSize, eTransformSpace, unTransformArrayCount):
"""Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array."""
fn = self.function_table.decompressSkeletalBoneData
pTransformArray = VRBoneTransform_t()
result = fn(pvCompressedBuffer, unCompressedBufferSize, eTransformSpace, byref(pTransformArray), unTransformArrayCount)
return result, pTransformArray
|
[
"def",
"decompressSkeletalBoneData",
"(",
"self",
",",
"pvCompressedBuffer",
",",
"unCompressedBufferSize",
",",
"eTransformSpace",
",",
"unTransformArrayCount",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"decompressSkeletalBoneData",
"pTransformArray",
"=",
"VRBoneTransform_t",
"(",
")",
"result",
"=",
"fn",
"(",
"pvCompressedBuffer",
",",
"unCompressedBufferSize",
",",
"eTransformSpace",
",",
"byref",
"(",
"pTransformArray",
")",
",",
"unTransformArrayCount",
")",
"return",
"result",
",",
"pTransformArray"
] |
Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array.
|
[
"Turns",
"a",
"compressed",
"buffer",
"from",
"GetSkeletalBoneDataCompressed",
"and",
"turns",
"it",
"back",
"into",
"a",
"bone",
"transform",
"array",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6095-L6101
|
15,744
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.triggerHapticVibrationAction
|
def triggerHapticVibrationAction(self, action, fStartSecondsFromNow, fDurationSeconds, fFrequency, fAmplitude, ulRestrictToDevice):
"""Triggers a haptic event as described by the specified action"""
fn = self.function_table.triggerHapticVibrationAction
result = fn(action, fStartSecondsFromNow, fDurationSeconds, fFrequency, fAmplitude, ulRestrictToDevice)
return result
|
python
|
def triggerHapticVibrationAction(self, action, fStartSecondsFromNow, fDurationSeconds, fFrequency, fAmplitude, ulRestrictToDevice):
"""Triggers a haptic event as described by the specified action"""
fn = self.function_table.triggerHapticVibrationAction
result = fn(action, fStartSecondsFromNow, fDurationSeconds, fFrequency, fAmplitude, ulRestrictToDevice)
return result
|
[
"def",
"triggerHapticVibrationAction",
"(",
"self",
",",
"action",
",",
"fStartSecondsFromNow",
",",
"fDurationSeconds",
",",
"fFrequency",
",",
"fAmplitude",
",",
"ulRestrictToDevice",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"triggerHapticVibrationAction",
"result",
"=",
"fn",
"(",
"action",
",",
"fStartSecondsFromNow",
",",
"fDurationSeconds",
",",
"fFrequency",
",",
"fAmplitude",
",",
"ulRestrictToDevice",
")",
"return",
"result"
] |
Triggers a haptic event as described by the specified action
|
[
"Triggers",
"a",
"haptic",
"event",
"as",
"described",
"by",
"the",
"specified",
"action"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6103-L6108
|
15,745
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getActionOrigins
|
def getActionOrigins(self, actionSetHandle, digitalActionHandle, originOutCount):
"""Retrieve origin handles for an action"""
fn = self.function_table.getActionOrigins
originsOut = VRInputValueHandle_t()
result = fn(actionSetHandle, digitalActionHandle, byref(originsOut), originOutCount)
return result, originsOut
|
python
|
def getActionOrigins(self, actionSetHandle, digitalActionHandle, originOutCount):
"""Retrieve origin handles for an action"""
fn = self.function_table.getActionOrigins
originsOut = VRInputValueHandle_t()
result = fn(actionSetHandle, digitalActionHandle, byref(originsOut), originOutCount)
return result, originsOut
|
[
"def",
"getActionOrigins",
"(",
"self",
",",
"actionSetHandle",
",",
"digitalActionHandle",
",",
"originOutCount",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getActionOrigins",
"originsOut",
"=",
"VRInputValueHandle_t",
"(",
")",
"result",
"=",
"fn",
"(",
"actionSetHandle",
",",
"digitalActionHandle",
",",
"byref",
"(",
"originsOut",
")",
",",
"originOutCount",
")",
"return",
"result",
",",
"originsOut"
] |
Retrieve origin handles for an action
|
[
"Retrieve",
"origin",
"handles",
"for",
"an",
"action"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6110-L6116
|
15,746
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getOriginLocalizedName
|
def getOriginLocalizedName(self, origin, pchNameArray, unNameArraySize, unStringSectionsToInclude):
"""
Retrieves the name of the origin in the current language. unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the
application to specify which parts of the origin's information it wants a string for.
"""
fn = self.function_table.getOriginLocalizedName
result = fn(origin, pchNameArray, unNameArraySize, unStringSectionsToInclude)
return result
|
python
|
def getOriginLocalizedName(self, origin, pchNameArray, unNameArraySize, unStringSectionsToInclude):
"""
Retrieves the name of the origin in the current language. unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the
application to specify which parts of the origin's information it wants a string for.
"""
fn = self.function_table.getOriginLocalizedName
result = fn(origin, pchNameArray, unNameArraySize, unStringSectionsToInclude)
return result
|
[
"def",
"getOriginLocalizedName",
"(",
"self",
",",
"origin",
",",
"pchNameArray",
",",
"unNameArraySize",
",",
"unStringSectionsToInclude",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getOriginLocalizedName",
"result",
"=",
"fn",
"(",
"origin",
",",
"pchNameArray",
",",
"unNameArraySize",
",",
"unStringSectionsToInclude",
")",
"return",
"result"
] |
Retrieves the name of the origin in the current language. unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the
application to specify which parts of the origin's information it wants a string for.
|
[
"Retrieves",
"the",
"name",
"of",
"the",
"origin",
"in",
"the",
"current",
"language",
".",
"unStringSectionsToInclude",
"is",
"a",
"bitfield",
"of",
"values",
"in",
"EVRInputStringBits",
"that",
"allows",
"the",
"application",
"to",
"specify",
"which",
"parts",
"of",
"the",
"origin",
"s",
"information",
"it",
"wants",
"a",
"string",
"for",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6118-L6126
|
15,747
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.getOriginTrackedDeviceInfo
|
def getOriginTrackedDeviceInfo(self, origin, unOriginInfoSize):
"""Retrieves useful information for the origin of this action"""
fn = self.function_table.getOriginTrackedDeviceInfo
pOriginInfo = InputOriginInfo_t()
result = fn(origin, byref(pOriginInfo), unOriginInfoSize)
return result, pOriginInfo
|
python
|
def getOriginTrackedDeviceInfo(self, origin, unOriginInfoSize):
"""Retrieves useful information for the origin of this action"""
fn = self.function_table.getOriginTrackedDeviceInfo
pOriginInfo = InputOriginInfo_t()
result = fn(origin, byref(pOriginInfo), unOriginInfoSize)
return result, pOriginInfo
|
[
"def",
"getOriginTrackedDeviceInfo",
"(",
"self",
",",
"origin",
",",
"unOriginInfoSize",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"getOriginTrackedDeviceInfo",
"pOriginInfo",
"=",
"InputOriginInfo_t",
"(",
")",
"result",
"=",
"fn",
"(",
"origin",
",",
"byref",
"(",
"pOriginInfo",
")",
",",
"unOriginInfoSize",
")",
"return",
"result",
",",
"pOriginInfo"
] |
Retrieves useful information for the origin of this action
|
[
"Retrieves",
"useful",
"information",
"for",
"the",
"origin",
"of",
"this",
"action"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6128-L6134
|
15,748
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.showActionOrigins
|
def showActionOrigins(self, actionSetHandle, ulActionHandle):
"""Shows the current binding for the action in-headset"""
fn = self.function_table.showActionOrigins
result = fn(actionSetHandle, ulActionHandle)
return result
|
python
|
def showActionOrigins(self, actionSetHandle, ulActionHandle):
"""Shows the current binding for the action in-headset"""
fn = self.function_table.showActionOrigins
result = fn(actionSetHandle, ulActionHandle)
return result
|
[
"def",
"showActionOrigins",
"(",
"self",
",",
"actionSetHandle",
",",
"ulActionHandle",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"showActionOrigins",
"result",
"=",
"fn",
"(",
"actionSetHandle",
",",
"ulActionHandle",
")",
"return",
"result"
] |
Shows the current binding for the action in-headset
|
[
"Shows",
"the",
"current",
"binding",
"for",
"the",
"action",
"in",
"-",
"headset"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6136-L6141
|
15,749
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRInput.showBindingsForActionSet
|
def showBindingsForActionSet(self, unSizeOfVRSelectedActionSet_t, unSetCount, originToHighlight):
"""Shows the current binding all the actions in the specified action sets"""
fn = self.function_table.showBindingsForActionSet
pSets = VRActiveActionSet_t()
result = fn(byref(pSets), unSizeOfVRSelectedActionSet_t, unSetCount, originToHighlight)
return result, pSets
|
python
|
def showBindingsForActionSet(self, unSizeOfVRSelectedActionSet_t, unSetCount, originToHighlight):
"""Shows the current binding all the actions in the specified action sets"""
fn = self.function_table.showBindingsForActionSet
pSets = VRActiveActionSet_t()
result = fn(byref(pSets), unSizeOfVRSelectedActionSet_t, unSetCount, originToHighlight)
return result, pSets
|
[
"def",
"showBindingsForActionSet",
"(",
"self",
",",
"unSizeOfVRSelectedActionSet_t",
",",
"unSetCount",
",",
"originToHighlight",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"showBindingsForActionSet",
"pSets",
"=",
"VRActiveActionSet_t",
"(",
")",
"result",
"=",
"fn",
"(",
"byref",
"(",
"pSets",
")",
",",
"unSizeOfVRSelectedActionSet_t",
",",
"unSetCount",
",",
"originToHighlight",
")",
"return",
"result",
",",
"pSets"
] |
Shows the current binding all the actions in the specified action sets
|
[
"Shows",
"the",
"current",
"binding",
"all",
"the",
"actions",
"in",
"the",
"specified",
"action",
"sets"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6143-L6149
|
15,750
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRIOBuffer.open
|
def open(self, pchPath, mode, unElementSize, unElements):
"""opens an existing or creates a new IOBuffer of unSize bytes"""
fn = self.function_table.open
pulBuffer = IOBufferHandle_t()
result = fn(pchPath, mode, unElementSize, unElements, byref(pulBuffer))
return result, pulBuffer
|
python
|
def open(self, pchPath, mode, unElementSize, unElements):
"""opens an existing or creates a new IOBuffer of unSize bytes"""
fn = self.function_table.open
pulBuffer = IOBufferHandle_t()
result = fn(pchPath, mode, unElementSize, unElements, byref(pulBuffer))
return result, pulBuffer
|
[
"def",
"open",
"(",
"self",
",",
"pchPath",
",",
"mode",
",",
"unElementSize",
",",
"unElements",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"open",
"pulBuffer",
"=",
"IOBufferHandle_t",
"(",
")",
"result",
"=",
"fn",
"(",
"pchPath",
",",
"mode",
",",
"unElementSize",
",",
"unElements",
",",
"byref",
"(",
"pulBuffer",
")",
")",
"return",
"result",
",",
"pulBuffer"
] |
opens an existing or creates a new IOBuffer of unSize bytes
|
[
"opens",
"an",
"existing",
"or",
"creates",
"a",
"new",
"IOBuffer",
"of",
"unSize",
"bytes"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6190-L6196
|
15,751
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRIOBuffer.close
|
def close(self, ulBuffer):
"""closes a previously opened or created buffer"""
fn = self.function_table.close
result = fn(ulBuffer)
return result
|
python
|
def close(self, ulBuffer):
"""closes a previously opened or created buffer"""
fn = self.function_table.close
result = fn(ulBuffer)
return result
|
[
"def",
"close",
"(",
"self",
",",
"ulBuffer",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"close",
"result",
"=",
"fn",
"(",
"ulBuffer",
")",
"return",
"result"
] |
closes a previously opened or created buffer
|
[
"closes",
"a",
"previously",
"opened",
"or",
"created",
"buffer"
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6198-L6203
|
15,752
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRIOBuffer.propertyContainer
|
def propertyContainer(self, ulBuffer):
"""retrieves the property container of an buffer."""
fn = self.function_table.propertyContainer
result = fn(ulBuffer)
return result
|
python
|
def propertyContainer(self, ulBuffer):
"""retrieves the property container of an buffer."""
fn = self.function_table.propertyContainer
result = fn(ulBuffer)
return result
|
[
"def",
"propertyContainer",
"(",
"self",
",",
"ulBuffer",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"propertyContainer",
"result",
"=",
"fn",
"(",
"ulBuffer",
")",
"return",
"result"
] |
retrieves the property container of an buffer.
|
[
"retrieves",
"the",
"property",
"container",
"of",
"an",
"buffer",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6220-L6225
|
15,753
|
cmbruns/pyopenvr
|
src/openvr/__init__.py
|
IVRIOBuffer.hasReaders
|
def hasReaders(self, ulBuffer):
"""inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes."""
fn = self.function_table.hasReaders
result = fn(ulBuffer)
return result
|
python
|
def hasReaders(self, ulBuffer):
"""inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes."""
fn = self.function_table.hasReaders
result = fn(ulBuffer)
return result
|
[
"def",
"hasReaders",
"(",
"self",
",",
"ulBuffer",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"hasReaders",
"result",
"=",
"fn",
"(",
"ulBuffer",
")",
"return",
"result"
] |
inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes.
|
[
"inexpensively",
"checks",
"for",
"readers",
"to",
"allow",
"writers",
"to",
"fast",
"-",
"fail",
"potentially",
"expensive",
"copies",
"and",
"writes",
"."
] |
68395d26bb3df6ab1f0f059c38d441f962938be6
|
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6227-L6232
|
15,754
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.execute
|
async def execute(self, sql, *params):
"""Executes the given operation substituting any markers with
the given parameters.
:param sql: the SQL statement to execute with optional ? parameter
markers. Note that pyodbc never modifies the SQL statement.
:param params: optional parameters for the markers in the SQL. They
can be passed in a single sequence as defined by the DB API.
For convenience, however, they can also be passed individually
"""
if self._echo:
logger.info(sql)
logger.info("%r", sql)
await self._run_operation(self._impl.execute, sql, *params)
return self
|
python
|
async def execute(self, sql, *params):
"""Executes the given operation substituting any markers with
the given parameters.
:param sql: the SQL statement to execute with optional ? parameter
markers. Note that pyodbc never modifies the SQL statement.
:param params: optional parameters for the markers in the SQL. They
can be passed in a single sequence as defined by the DB API.
For convenience, however, they can also be passed individually
"""
if self._echo:
logger.info(sql)
logger.info("%r", sql)
await self._run_operation(self._impl.execute, sql, *params)
return self
|
[
"async",
"def",
"execute",
"(",
"self",
",",
"sql",
",",
"*",
"params",
")",
":",
"if",
"self",
".",
"_echo",
":",
"logger",
".",
"info",
"(",
"sql",
")",
"logger",
".",
"info",
"(",
"\"%r\"",
",",
"sql",
")",
"await",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"execute",
",",
"sql",
",",
"*",
"params",
")",
"return",
"self"
] |
Executes the given operation substituting any markers with
the given parameters.
:param sql: the SQL statement to execute with optional ? parameter
markers. Note that pyodbc never modifies the SQL statement.
:param params: optional parameters for the markers in the SQL. They
can be passed in a single sequence as defined by the DB API.
For convenience, however, they can also be passed individually
|
[
"Executes",
"the",
"given",
"operation",
"substituting",
"any",
"markers",
"with",
"the",
"given",
"parameters",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L108-L122
|
15,755
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.executemany
|
def executemany(self, sql, *params):
"""Prepare a database query or command and then execute it against
all parameter sequences found in the sequence seq_of_params.
:param sql: the SQL statement to execute with optional ? parameters
:param params: sequence parameters for the markers in the SQL.
"""
fut = self._run_operation(self._impl.executemany, sql, *params)
return fut
|
python
|
def executemany(self, sql, *params):
"""Prepare a database query or command and then execute it against
all parameter sequences found in the sequence seq_of_params.
:param sql: the SQL statement to execute with optional ? parameters
:param params: sequence parameters for the markers in the SQL.
"""
fut = self._run_operation(self._impl.executemany, sql, *params)
return fut
|
[
"def",
"executemany",
"(",
"self",
",",
"sql",
",",
"*",
"params",
")",
":",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"executemany",
",",
"sql",
",",
"*",
"params",
")",
"return",
"fut"
] |
Prepare a database query or command and then execute it against
all parameter sequences found in the sequence seq_of_params.
:param sql: the SQL statement to execute with optional ? parameters
:param params: sequence parameters for the markers in the SQL.
|
[
"Prepare",
"a",
"database",
"query",
"or",
"command",
"and",
"then",
"execute",
"it",
"against",
"all",
"parameter",
"sequences",
"found",
"in",
"the",
"sequence",
"seq_of_params",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L124-L132
|
15,756
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.fetchmany
|
def fetchmany(self, size):
"""Returns a list of remaining rows, containing no more than size
rows, used to process results in chunks. The list will be empty when
there are no more rows.
The default for cursor.arraysize is 1 which is no different than
calling fetchone().
A ProgrammingError exception is raised if no SQL has been executed
or if it did not return a result set (e.g. was not a SELECT
statement).
:param size: int, max number of rows to return
"""
fut = self._run_operation(self._impl.fetchmany, size)
return fut
|
python
|
def fetchmany(self, size):
"""Returns a list of remaining rows, containing no more than size
rows, used to process results in chunks. The list will be empty when
there are no more rows.
The default for cursor.arraysize is 1 which is no different than
calling fetchone().
A ProgrammingError exception is raised if no SQL has been executed
or if it did not return a result set (e.g. was not a SELECT
statement).
:param size: int, max number of rows to return
"""
fut = self._run_operation(self._impl.fetchmany, size)
return fut
|
[
"def",
"fetchmany",
"(",
"self",
",",
"size",
")",
":",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"fetchmany",
",",
"size",
")",
"return",
"fut"
] |
Returns a list of remaining rows, containing no more than size
rows, used to process results in chunks. The list will be empty when
there are no more rows.
The default for cursor.arraysize is 1 which is no different than
calling fetchone().
A ProgrammingError exception is raised if no SQL has been executed
or if it did not return a result set (e.g. was not a SELECT
statement).
:param size: int, max number of rows to return
|
[
"Returns",
"a",
"list",
"of",
"remaining",
"rows",
"containing",
"no",
"more",
"than",
"size",
"rows",
"used",
"to",
"process",
"results",
"in",
"chunks",
".",
"The",
"list",
"will",
"be",
"empty",
"when",
"there",
"are",
"no",
"more",
"rows",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L169-L184
|
15,757
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.tables
|
def tables(self, **kw):
"""Creates a result set of tables in the database that match the
given criteria.
:param table: the table tname
:param catalog: the catalog name
:param schema: the schmea name
:param tableType: one of TABLE, VIEW, SYSTEM TABLE ...
"""
fut = self._run_operation(self._impl.tables, **kw)
return fut
|
python
|
def tables(self, **kw):
"""Creates a result set of tables in the database that match the
given criteria.
:param table: the table tname
:param catalog: the catalog name
:param schema: the schmea name
:param tableType: one of TABLE, VIEW, SYSTEM TABLE ...
"""
fut = self._run_operation(self._impl.tables, **kw)
return fut
|
[
"def",
"tables",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"tables",
",",
"*",
"*",
"kw",
")",
"return",
"fut"
] |
Creates a result set of tables in the database that match the
given criteria.
:param table: the table tname
:param catalog: the catalog name
:param schema: the schmea name
:param tableType: one of TABLE, VIEW, SYSTEM TABLE ...
|
[
"Creates",
"a",
"result",
"set",
"of",
"tables",
"in",
"the",
"database",
"that",
"match",
"the",
"given",
"criteria",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L200-L210
|
15,758
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.columns
|
def columns(self, **kw):
"""Creates a results set of column names in specified tables by
executing the ODBC SQLColumns function. Each row fetched has the
following columns.
:param table: the table tname
:param catalog: the catalog name
:param schema: the schmea name
:param column: string search pattern for column names.
"""
fut = self._run_operation(self._impl.columns, **kw)
return fut
|
python
|
def columns(self, **kw):
"""Creates a results set of column names in specified tables by
executing the ODBC SQLColumns function. Each row fetched has the
following columns.
:param table: the table tname
:param catalog: the catalog name
:param schema: the schmea name
:param column: string search pattern for column names.
"""
fut = self._run_operation(self._impl.columns, **kw)
return fut
|
[
"def",
"columns",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"columns",
",",
"*",
"*",
"kw",
")",
"return",
"fut"
] |
Creates a results set of column names in specified tables by
executing the ODBC SQLColumns function. Each row fetched has the
following columns.
:param table: the table tname
:param catalog: the catalog name
:param schema: the schmea name
:param column: string search pattern for column names.
|
[
"Creates",
"a",
"results",
"set",
"of",
"column",
"names",
"in",
"specified",
"tables",
"by",
"executing",
"the",
"ODBC",
"SQLColumns",
"function",
".",
"Each",
"row",
"fetched",
"has",
"the",
"following",
"columns",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L212-L223
|
15,759
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.statistics
|
def statistics(self, catalog=None, schema=None, unique=False, quick=True):
"""Creates a results set of statistics about a single table and
the indexes associated with the table by executing SQLStatistics.
:param catalog: the catalog name
:param schema: the schmea name
:param unique: if True, only unique indexes are retured. Otherwise
all indexes are returned.
:param quick: if True, CARDINALITY and PAGES are returned only if
they are readily available from the server
"""
fut = self._run_operation(self._impl.statistics, catalog=catalog,
schema=schema, unique=unique, quick=quick)
return fut
|
python
|
def statistics(self, catalog=None, schema=None, unique=False, quick=True):
"""Creates a results set of statistics about a single table and
the indexes associated with the table by executing SQLStatistics.
:param catalog: the catalog name
:param schema: the schmea name
:param unique: if True, only unique indexes are retured. Otherwise
all indexes are returned.
:param quick: if True, CARDINALITY and PAGES are returned only if
they are readily available from the server
"""
fut = self._run_operation(self._impl.statistics, catalog=catalog,
schema=schema, unique=unique, quick=quick)
return fut
|
[
"def",
"statistics",
"(",
"self",
",",
"catalog",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"unique",
"=",
"False",
",",
"quick",
"=",
"True",
")",
":",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"statistics",
",",
"catalog",
"=",
"catalog",
",",
"schema",
"=",
"schema",
",",
"unique",
"=",
"unique",
",",
"quick",
"=",
"quick",
")",
"return",
"fut"
] |
Creates a results set of statistics about a single table and
the indexes associated with the table by executing SQLStatistics.
:param catalog: the catalog name
:param schema: the schmea name
:param unique: if True, only unique indexes are retured. Otherwise
all indexes are returned.
:param quick: if True, CARDINALITY and PAGES are returned only if
they are readily available from the server
|
[
"Creates",
"a",
"results",
"set",
"of",
"statistics",
"about",
"a",
"single",
"table",
"and",
"the",
"indexes",
"associated",
"with",
"the",
"table",
"by",
"executing",
"SQLStatistics",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L225-L238
|
15,760
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.rowIdColumns
|
def rowIdColumns(self, table, catalog=None, schema=None, # nopep8
nullable=True):
"""Executes SQLSpecialColumns with SQL_BEST_ROWID which creates a
result set of columns that uniquely identify a row
"""
fut = self._run_operation(self._impl.rowIdColumns, table,
catalog=catalog, schema=schema,
nullable=nullable)
return fut
|
python
|
def rowIdColumns(self, table, catalog=None, schema=None, # nopep8
nullable=True):
"""Executes SQLSpecialColumns with SQL_BEST_ROWID which creates a
result set of columns that uniquely identify a row
"""
fut = self._run_operation(self._impl.rowIdColumns, table,
catalog=catalog, schema=schema,
nullable=nullable)
return fut
|
[
"def",
"rowIdColumns",
"(",
"self",
",",
"table",
",",
"catalog",
"=",
"None",
",",
"schema",
"=",
"None",
",",
"# nopep8",
"nullable",
"=",
"True",
")",
":",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"rowIdColumns",
",",
"table",
",",
"catalog",
"=",
"catalog",
",",
"schema",
"=",
"schema",
",",
"nullable",
"=",
"nullable",
")",
"return",
"fut"
] |
Executes SQLSpecialColumns with SQL_BEST_ROWID which creates a
result set of columns that uniquely identify a row
|
[
"Executes",
"SQLSpecialColumns",
"with",
"SQL_BEST_ROWID",
"which",
"creates",
"a",
"result",
"set",
"of",
"columns",
"that",
"uniquely",
"identify",
"a",
"row"
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L240-L248
|
15,761
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.primaryKeys
|
def primaryKeys(self, table, catalog=None, schema=None): # nopep8
"""Creates a result set of column names that make up the primary key
for a table by executing the SQLPrimaryKeys function."""
fut = self._run_operation(self._impl.primaryKeys, table,
catalog=catalog, schema=schema)
return fut
|
python
|
def primaryKeys(self, table, catalog=None, schema=None): # nopep8
"""Creates a result set of column names that make up the primary key
for a table by executing the SQLPrimaryKeys function."""
fut = self._run_operation(self._impl.primaryKeys, table,
catalog=catalog, schema=schema)
return fut
|
[
"def",
"primaryKeys",
"(",
"self",
",",
"table",
",",
"catalog",
"=",
"None",
",",
"schema",
"=",
"None",
")",
":",
"# nopep8",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"primaryKeys",
",",
"table",
",",
"catalog",
"=",
"catalog",
",",
"schema",
"=",
"schema",
")",
"return",
"fut"
] |
Creates a result set of column names that make up the primary key
for a table by executing the SQLPrimaryKeys function.
|
[
"Creates",
"a",
"result",
"set",
"of",
"column",
"names",
"that",
"make",
"up",
"the",
"primary",
"key",
"for",
"a",
"table",
"by",
"executing",
"the",
"SQLPrimaryKeys",
"function",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L261-L266
|
15,762
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.getTypeInfo
|
def getTypeInfo(self, sql_type): # nopep8
"""Executes SQLGetTypeInfo a creates a result set with information
about the specified data type or all data types supported by the
ODBC driver if not specified.
"""
fut = self._run_operation(self._impl.getTypeInfo, sql_type)
return fut
|
python
|
def getTypeInfo(self, sql_type): # nopep8
"""Executes SQLGetTypeInfo a creates a result set with information
about the specified data type or all data types supported by the
ODBC driver if not specified.
"""
fut = self._run_operation(self._impl.getTypeInfo, sql_type)
return fut
|
[
"def",
"getTypeInfo",
"(",
"self",
",",
"sql_type",
")",
":",
"# nopep8",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"getTypeInfo",
",",
"sql_type",
")",
"return",
"fut"
] |
Executes SQLGetTypeInfo a creates a result set with information
about the specified data type or all data types supported by the
ODBC driver if not specified.
|
[
"Executes",
"SQLGetTypeInfo",
"a",
"creates",
"a",
"result",
"set",
"with",
"information",
"about",
"the",
"specified",
"data",
"type",
"or",
"all",
"data",
"types",
"supported",
"by",
"the",
"ODBC",
"driver",
"if",
"not",
"specified",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L278-L284
|
15,763
|
aio-libs/aioodbc
|
aioodbc/cursor.py
|
Cursor.procedures
|
def procedures(self, *a, **kw):
"""Executes SQLProcedures and creates a result set of information
about the procedures in the data source.
"""
fut = self._run_operation(self._impl.procedures, *a, **kw)
return fut
|
python
|
def procedures(self, *a, **kw):
"""Executes SQLProcedures and creates a result set of information
about the procedures in the data source.
"""
fut = self._run_operation(self._impl.procedures, *a, **kw)
return fut
|
[
"def",
"procedures",
"(",
"self",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"fut",
"=",
"self",
".",
"_run_operation",
"(",
"self",
".",
"_impl",
".",
"procedures",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")",
"return",
"fut"
] |
Executes SQLProcedures and creates a result set of information
about the procedures in the data source.
|
[
"Executes",
"SQLProcedures",
"and",
"creates",
"a",
"result",
"set",
"of",
"information",
"about",
"the",
"procedures",
"in",
"the",
"data",
"source",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L286-L291
|
15,764
|
aio-libs/aioodbc
|
aioodbc/__init__.py
|
dataSources
|
async def dataSources(loop=None, executor=None):
"""Returns a dictionary mapping available DSNs to their descriptions.
:param loop: asyncio compatible event loop
:param executor: instance of custom ThreadPoolExecutor, if not supplied
default executor will be used
:return dict: mapping of dsn to driver description
"""
loop = loop or asyncio.get_event_loop()
sources = await loop.run_in_executor(executor, _dataSources)
return sources
|
python
|
async def dataSources(loop=None, executor=None):
"""Returns a dictionary mapping available DSNs to their descriptions.
:param loop: asyncio compatible event loop
:param executor: instance of custom ThreadPoolExecutor, if not supplied
default executor will be used
:return dict: mapping of dsn to driver description
"""
loop = loop or asyncio.get_event_loop()
sources = await loop.run_in_executor(executor, _dataSources)
return sources
|
[
"async",
"def",
"dataSources",
"(",
"loop",
"=",
"None",
",",
"executor",
"=",
"None",
")",
":",
"loop",
"=",
"loop",
"or",
"asyncio",
".",
"get_event_loop",
"(",
")",
"sources",
"=",
"await",
"loop",
".",
"run_in_executor",
"(",
"executor",
",",
"_dataSources",
")",
"return",
"sources"
] |
Returns a dictionary mapping available DSNs to their descriptions.
:param loop: asyncio compatible event loop
:param executor: instance of custom ThreadPoolExecutor, if not supplied
default executor will be used
:return dict: mapping of dsn to driver description
|
[
"Returns",
"a",
"dictionary",
"mapping",
"available",
"DSNs",
"to",
"their",
"descriptions",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/__init__.py#L14-L24
|
15,765
|
aio-libs/aioodbc
|
aioodbc/connection.py
|
connect
|
def connect(*, dsn, autocommit=False, ansi=False, timeout=0, loop=None,
executor=None, echo=False, after_created=None, **kwargs):
"""Accepts an ODBC connection string and returns a new Connection object.
The connection string can be passed as the string `str`, as a list of
keywords,or a combination of the two. Any keywords except autocommit,
ansi, and timeout are simply added to the connection string.
:param autocommit bool: False or zero, the default, if True or non-zero,
the connection is put into ODBC autocommit mode and statements are
committed automatically.
:param ansi bool: By default, pyodbc first attempts to connect using
the Unicode version of SQLDriverConnectW. If the driver returns IM001
indicating it does not support the Unicode version, the ANSI version
is tried.
:param timeout int: An integer login timeout in seconds, used to set
the SQL_ATTR_LOGIN_TIMEOUT attribute of the connection. The default is
0 which means the database's default timeout, if any, is use
:param after_created callable: support customize configuration after
connection is connected. Must be an async unary function, or leave it
as None.
"""
return _ContextManager(_connect(dsn=dsn, autocommit=autocommit,
ansi=ansi, timeout=timeout, loop=loop,
executor=executor, echo=echo,
after_created=after_created, **kwargs))
|
python
|
def connect(*, dsn, autocommit=False, ansi=False, timeout=0, loop=None,
executor=None, echo=False, after_created=None, **kwargs):
"""Accepts an ODBC connection string and returns a new Connection object.
The connection string can be passed as the string `str`, as a list of
keywords,or a combination of the two. Any keywords except autocommit,
ansi, and timeout are simply added to the connection string.
:param autocommit bool: False or zero, the default, if True or non-zero,
the connection is put into ODBC autocommit mode and statements are
committed automatically.
:param ansi bool: By default, pyodbc first attempts to connect using
the Unicode version of SQLDriverConnectW. If the driver returns IM001
indicating it does not support the Unicode version, the ANSI version
is tried.
:param timeout int: An integer login timeout in seconds, used to set
the SQL_ATTR_LOGIN_TIMEOUT attribute of the connection. The default is
0 which means the database's default timeout, if any, is use
:param after_created callable: support customize configuration after
connection is connected. Must be an async unary function, or leave it
as None.
"""
return _ContextManager(_connect(dsn=dsn, autocommit=autocommit,
ansi=ansi, timeout=timeout, loop=loop,
executor=executor, echo=echo,
after_created=after_created, **kwargs))
|
[
"def",
"connect",
"(",
"*",
",",
"dsn",
",",
"autocommit",
"=",
"False",
",",
"ansi",
"=",
"False",
",",
"timeout",
"=",
"0",
",",
"loop",
"=",
"None",
",",
"executor",
"=",
"None",
",",
"echo",
"=",
"False",
",",
"after_created",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_ContextManager",
"(",
"_connect",
"(",
"dsn",
"=",
"dsn",
",",
"autocommit",
"=",
"autocommit",
",",
"ansi",
"=",
"ansi",
",",
"timeout",
"=",
"timeout",
",",
"loop",
"=",
"loop",
",",
"executor",
"=",
"executor",
",",
"echo",
"=",
"echo",
",",
"after_created",
"=",
"after_created",
",",
"*",
"*",
"kwargs",
")",
")"
] |
Accepts an ODBC connection string and returns a new Connection object.
The connection string can be passed as the string `str`, as a list of
keywords,or a combination of the two. Any keywords except autocommit,
ansi, and timeout are simply added to the connection string.
:param autocommit bool: False or zero, the default, if True or non-zero,
the connection is put into ODBC autocommit mode and statements are
committed automatically.
:param ansi bool: By default, pyodbc first attempts to connect using
the Unicode version of SQLDriverConnectW. If the driver returns IM001
indicating it does not support the Unicode version, the ANSI version
is tried.
:param timeout int: An integer login timeout in seconds, used to set
the SQL_ATTR_LOGIN_TIMEOUT attribute of the connection. The default is
0 which means the database's default timeout, if any, is use
:param after_created callable: support customize configuration after
connection is connected. Must be an async unary function, or leave it
as None.
|
[
"Accepts",
"an",
"ODBC",
"connection",
"string",
"and",
"returns",
"a",
"new",
"Connection",
"object",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L15-L40
|
15,766
|
aio-libs/aioodbc
|
aioodbc/connection.py
|
Connection.close
|
async def close(self):
"""Close pyodbc connection"""
if not self._conn:
return
c = await self._execute(self._conn.close)
self._conn = None
return c
|
python
|
async def close(self):
"""Close pyodbc connection"""
if not self._conn:
return
c = await self._execute(self._conn.close)
self._conn = None
return c
|
[
"async",
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_conn",
":",
"return",
"c",
"=",
"await",
"self",
".",
"_execute",
"(",
"self",
".",
"_conn",
".",
"close",
")",
"self",
".",
"_conn",
"=",
"None",
"return",
"c"
] |
Close pyodbc connection
|
[
"Close",
"pyodbc",
"connection"
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L133-L139
|
15,767
|
aio-libs/aioodbc
|
aioodbc/connection.py
|
Connection.execute
|
async def execute(self, sql, *args):
"""Create a new Cursor object, call its execute method, and return it.
See Cursor.execute for more details.This is a convenience method
that is not part of the DB API. Since a new Cursor is allocated
by each call, this should not be used if more than one SQL
statement needs to be executed.
:param sql: str, formated sql statement
:param args: tuple, arguments for construction of sql statement
"""
_cursor = await self._execute(self._conn.execute, sql, *args)
connection = self
cursor = Cursor(_cursor, connection, echo=self._echo)
return cursor
|
python
|
async def execute(self, sql, *args):
"""Create a new Cursor object, call its execute method, and return it.
See Cursor.execute for more details.This is a convenience method
that is not part of the DB API. Since a new Cursor is allocated
by each call, this should not be used if more than one SQL
statement needs to be executed.
:param sql: str, formated sql statement
:param args: tuple, arguments for construction of sql statement
"""
_cursor = await self._execute(self._conn.execute, sql, *args)
connection = self
cursor = Cursor(_cursor, connection, echo=self._echo)
return cursor
|
[
"async",
"def",
"execute",
"(",
"self",
",",
"sql",
",",
"*",
"args",
")",
":",
"_cursor",
"=",
"await",
"self",
".",
"_execute",
"(",
"self",
".",
"_conn",
".",
"execute",
",",
"sql",
",",
"*",
"args",
")",
"connection",
"=",
"self",
"cursor",
"=",
"Cursor",
"(",
"_cursor",
",",
"connection",
",",
"echo",
"=",
"self",
".",
"_echo",
")",
"return",
"cursor"
] |
Create a new Cursor object, call its execute method, and return it.
See Cursor.execute for more details.This is a convenience method
that is not part of the DB API. Since a new Cursor is allocated
by each call, this should not be used if more than one SQL
statement needs to be executed.
:param sql: str, formated sql statement
:param args: tuple, arguments for construction of sql statement
|
[
"Create",
"a",
"new",
"Cursor",
"object",
"call",
"its",
"execute",
"method",
"and",
"return",
"it",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L153-L167
|
15,768
|
aio-libs/aioodbc
|
aioodbc/connection.py
|
Connection.getinfo
|
def getinfo(self, type_):
"""Returns general information about the driver and data source
associated with a connection by calling SQLGetInfo and returning its
results. See Microsoft's SQLGetInfo documentation for the types of
information available.
:param type_: int, pyodbc.SQL_* constant
"""
fut = self._execute(self._conn.getinfo, type_)
return fut
|
python
|
def getinfo(self, type_):
"""Returns general information about the driver and data source
associated with a connection by calling SQLGetInfo and returning its
results. See Microsoft's SQLGetInfo documentation for the types of
information available.
:param type_: int, pyodbc.SQL_* constant
"""
fut = self._execute(self._conn.getinfo, type_)
return fut
|
[
"def",
"getinfo",
"(",
"self",
",",
"type_",
")",
":",
"fut",
"=",
"self",
".",
"_execute",
"(",
"self",
".",
"_conn",
".",
"getinfo",
",",
"type_",
")",
"return",
"fut"
] |
Returns general information about the driver and data source
associated with a connection by calling SQLGetInfo and returning its
results. See Microsoft's SQLGetInfo documentation for the types of
information available.
:param type_: int, pyodbc.SQL_* constant
|
[
"Returns",
"general",
"information",
"about",
"the",
"driver",
"and",
"data",
"source",
"associated",
"with",
"a",
"connection",
"by",
"calling",
"SQLGetInfo",
"and",
"returning",
"its",
"results",
".",
"See",
"Microsoft",
"s",
"SQLGetInfo",
"documentation",
"for",
"the",
"types",
"of",
"information",
"available",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L169-L178
|
15,769
|
aio-libs/aioodbc
|
aioodbc/connection.py
|
Connection.add_output_converter
|
def add_output_converter(self, sqltype, func):
"""Register an output converter function that will be called whenever
a value with the given SQL type is read from the database.
:param sqltype: the integer SQL type value to convert, which can
be one of the defined standard constants (pyodbc.SQL_VARCHAR)
or a database-specific value (e.g. -151 for the SQL Server 2008
geometry data type).
:param func: the converter function which will be called with a
single parameter, the value, and should return the converted
value. If the value is NULL, the parameter will be None.
Otherwise it will be a Python string.
"""
fut = self._execute(self._conn.add_output_converter, sqltype, func)
return fut
|
python
|
def add_output_converter(self, sqltype, func):
"""Register an output converter function that will be called whenever
a value with the given SQL type is read from the database.
:param sqltype: the integer SQL type value to convert, which can
be one of the defined standard constants (pyodbc.SQL_VARCHAR)
or a database-specific value (e.g. -151 for the SQL Server 2008
geometry data type).
:param func: the converter function which will be called with a
single parameter, the value, and should return the converted
value. If the value is NULL, the parameter will be None.
Otherwise it will be a Python string.
"""
fut = self._execute(self._conn.add_output_converter, sqltype, func)
return fut
|
[
"def",
"add_output_converter",
"(",
"self",
",",
"sqltype",
",",
"func",
")",
":",
"fut",
"=",
"self",
".",
"_execute",
"(",
"self",
".",
"_conn",
".",
"add_output_converter",
",",
"sqltype",
",",
"func",
")",
"return",
"fut"
] |
Register an output converter function that will be called whenever
a value with the given SQL type is read from the database.
:param sqltype: the integer SQL type value to convert, which can
be one of the defined standard constants (pyodbc.SQL_VARCHAR)
or a database-specific value (e.g. -151 for the SQL Server 2008
geometry data type).
:param func: the converter function which will be called with a
single parameter, the value, and should return the converted
value. If the value is NULL, the parameter will be None.
Otherwise it will be a Python string.
|
[
"Register",
"an",
"output",
"converter",
"function",
"that",
"will",
"be",
"called",
"whenever",
"a",
"value",
"with",
"the",
"given",
"SQL",
"type",
"is",
"read",
"from",
"the",
"database",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L180-L194
|
15,770
|
aio-libs/aioodbc
|
aioodbc/connection.py
|
Connection.set_attr
|
def set_attr(self, attr_id, value):
"""Calls SQLSetConnectAttr with the given values.
:param attr_id: the attribute ID (integer) to set. These are ODBC or
driver constants.
:parm value: the connection attribute value to set. At this time
only integer values are supported.
"""
fut = self._execute(self._conn.set_attr, attr_id, value)
return fut
|
python
|
def set_attr(self, attr_id, value):
"""Calls SQLSetConnectAttr with the given values.
:param attr_id: the attribute ID (integer) to set. These are ODBC or
driver constants.
:parm value: the connection attribute value to set. At this time
only integer values are supported.
"""
fut = self._execute(self._conn.set_attr, attr_id, value)
return fut
|
[
"def",
"set_attr",
"(",
"self",
",",
"attr_id",
",",
"value",
")",
":",
"fut",
"=",
"self",
".",
"_execute",
"(",
"self",
".",
"_conn",
".",
"set_attr",
",",
"attr_id",
",",
"value",
")",
"return",
"fut"
] |
Calls SQLSetConnectAttr with the given values.
:param attr_id: the attribute ID (integer) to set. These are ODBC or
driver constants.
:parm value: the connection attribute value to set. At this time
only integer values are supported.
|
[
"Calls",
"SQLSetConnectAttr",
"with",
"the",
"given",
"values",
"."
] |
01245560828d4adce0d7d16930fa566102322a0a
|
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L203-L212
|
15,771
|
tsifrer/python-twitch-client
|
twitch/api/base.py
|
TwitchAPI._request_get
|
def _request_get(self, path, params=None, json=True, url=BASE_URL):
"""Perform a HTTP GET request."""
url = urljoin(url, path)
headers = self._get_request_headers()
response = requests.get(url, params=params, headers=headers)
if response.status_code >= 500:
backoff = self._initial_backoff
for _ in range(self._max_retries):
time.sleep(backoff)
backoff_response = requests.get(
url, params=params, headers=headers,
timeout=DEFAULT_TIMEOUT)
if backoff_response.status_code < 500:
response = backoff_response
break
backoff *= 2
response.raise_for_status()
if json:
return response.json()
else:
return response
|
python
|
def _request_get(self, path, params=None, json=True, url=BASE_URL):
"""Perform a HTTP GET request."""
url = urljoin(url, path)
headers = self._get_request_headers()
response = requests.get(url, params=params, headers=headers)
if response.status_code >= 500:
backoff = self._initial_backoff
for _ in range(self._max_retries):
time.sleep(backoff)
backoff_response = requests.get(
url, params=params, headers=headers,
timeout=DEFAULT_TIMEOUT)
if backoff_response.status_code < 500:
response = backoff_response
break
backoff *= 2
response.raise_for_status()
if json:
return response.json()
else:
return response
|
[
"def",
"_request_get",
"(",
"self",
",",
"path",
",",
"params",
"=",
"None",
",",
"json",
"=",
"True",
",",
"url",
"=",
"BASE_URL",
")",
":",
"url",
"=",
"urljoin",
"(",
"url",
",",
"path",
")",
"headers",
"=",
"self",
".",
"_get_request_headers",
"(",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"params",
"=",
"params",
",",
"headers",
"=",
"headers",
")",
"if",
"response",
".",
"status_code",
">=",
"500",
":",
"backoff",
"=",
"self",
".",
"_initial_backoff",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"_max_retries",
")",
":",
"time",
".",
"sleep",
"(",
"backoff",
")",
"backoff_response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"params",
"=",
"params",
",",
"headers",
"=",
"headers",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
"if",
"backoff_response",
".",
"status_code",
"<",
"500",
":",
"response",
"=",
"backoff_response",
"break",
"backoff",
"*=",
"2",
"response",
".",
"raise_for_status",
"(",
")",
"if",
"json",
":",
"return",
"response",
".",
"json",
"(",
")",
"else",
":",
"return",
"response"
] |
Perform a HTTP GET request.
|
[
"Perform",
"a",
"HTTP",
"GET",
"request",
"."
] |
d8eda09acddabe1a9fd9eb76b3f454fa827b5074
|
https://github.com/tsifrer/python-twitch-client/blob/d8eda09acddabe1a9fd9eb76b3f454fa827b5074/twitch/api/base.py#L34-L57
|
15,772
|
tsifrer/python-twitch-client
|
twitch/api/base.py
|
TwitchAPI._request_post
|
def _request_post(self, path, data=None, params=None, url=BASE_URL):
"""Perform a HTTP POST request.."""
url = urljoin(url, path)
headers = self._get_request_headers()
response = requests.post(
url, json=data, params=params, headers=headers,
timeout=DEFAULT_TIMEOUT)
response.raise_for_status()
if response.status_code == 200:
return response.json()
|
python
|
def _request_post(self, path, data=None, params=None, url=BASE_URL):
"""Perform a HTTP POST request.."""
url = urljoin(url, path)
headers = self._get_request_headers()
response = requests.post(
url, json=data, params=params, headers=headers,
timeout=DEFAULT_TIMEOUT)
response.raise_for_status()
if response.status_code == 200:
return response.json()
|
[
"def",
"_request_post",
"(",
"self",
",",
"path",
",",
"data",
"=",
"None",
",",
"params",
"=",
"None",
",",
"url",
"=",
"BASE_URL",
")",
":",
"url",
"=",
"urljoin",
"(",
"url",
",",
"path",
")",
"headers",
"=",
"self",
".",
"_get_request_headers",
"(",
")",
"response",
"=",
"requests",
".",
"post",
"(",
"url",
",",
"json",
"=",
"data",
",",
"params",
"=",
"params",
",",
"headers",
"=",
"headers",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
"response",
".",
"raise_for_status",
"(",
")",
"if",
"response",
".",
"status_code",
"==",
"200",
":",
"return",
"response",
".",
"json",
"(",
")"
] |
Perform a HTTP POST request..
|
[
"Perform",
"a",
"HTTP",
"POST",
"request",
".."
] |
d8eda09acddabe1a9fd9eb76b3f454fa827b5074
|
https://github.com/tsifrer/python-twitch-client/blob/d8eda09acddabe1a9fd9eb76b3f454fa827b5074/twitch/api/base.py#L59-L70
|
15,773
|
tsifrer/python-twitch-client
|
twitch/api/base.py
|
TwitchAPI._request_delete
|
def _request_delete(self, path, params=None, url=BASE_URL):
"""Perform a HTTP DELETE request."""
url = urljoin(url, path)
headers = self._get_request_headers()
response = requests.delete(
url, params=params, headers=headers, timeout=DEFAULT_TIMEOUT)
response.raise_for_status()
if response.status_code == 200:
return response.json()
|
python
|
def _request_delete(self, path, params=None, url=BASE_URL):
"""Perform a HTTP DELETE request."""
url = urljoin(url, path)
headers = self._get_request_headers()
response = requests.delete(
url, params=params, headers=headers, timeout=DEFAULT_TIMEOUT)
response.raise_for_status()
if response.status_code == 200:
return response.json()
|
[
"def",
"_request_delete",
"(",
"self",
",",
"path",
",",
"params",
"=",
"None",
",",
"url",
"=",
"BASE_URL",
")",
":",
"url",
"=",
"urljoin",
"(",
"url",
",",
"path",
")",
"headers",
"=",
"self",
".",
"_get_request_headers",
"(",
")",
"response",
"=",
"requests",
".",
"delete",
"(",
"url",
",",
"params",
"=",
"params",
",",
"headers",
"=",
"headers",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
"response",
".",
"raise_for_status",
"(",
")",
"if",
"response",
".",
"status_code",
"==",
"200",
":",
"return",
"response",
".",
"json",
"(",
")"
] |
Perform a HTTP DELETE request.
|
[
"Perform",
"a",
"HTTP",
"DELETE",
"request",
"."
] |
d8eda09acddabe1a9fd9eb76b3f454fa827b5074
|
https://github.com/tsifrer/python-twitch-client/blob/d8eda09acddabe1a9fd9eb76b3f454fa827b5074/twitch/api/base.py#L84-L94
|
15,774
|
jgorset/facepy
|
facepy/signed_request.py
|
SignedRequest.parse
|
def parse(cls, signed_request, application_secret_key):
"""Parse a signed request, returning a dictionary describing its payload."""
def decode(encoded):
padding = '=' * (len(encoded) % 4)
return base64.urlsafe_b64decode(encoded + padding)
try:
encoded_signature, encoded_payload = (str(string) for string in signed_request.split('.', 2))
signature = decode(encoded_signature)
signed_request_data = json.loads(decode(encoded_payload).decode('utf-8'))
except (TypeError, ValueError):
raise SignedRequestError("Signed request had a corrupt payload")
if signed_request_data.get('algorithm', '').upper() != 'HMAC-SHA256':
raise SignedRequestError("Signed request is using an unknown algorithm")
expected_signature = hmac.new(application_secret_key.encode('utf-8'), msg=encoded_payload.encode('utf-8'),
digestmod=hashlib.sha256).digest()
if signature != expected_signature:
raise SignedRequestError("Signed request signature mismatch")
return signed_request_data
|
python
|
def parse(cls, signed_request, application_secret_key):
"""Parse a signed request, returning a dictionary describing its payload."""
def decode(encoded):
padding = '=' * (len(encoded) % 4)
return base64.urlsafe_b64decode(encoded + padding)
try:
encoded_signature, encoded_payload = (str(string) for string in signed_request.split('.', 2))
signature = decode(encoded_signature)
signed_request_data = json.loads(decode(encoded_payload).decode('utf-8'))
except (TypeError, ValueError):
raise SignedRequestError("Signed request had a corrupt payload")
if signed_request_data.get('algorithm', '').upper() != 'HMAC-SHA256':
raise SignedRequestError("Signed request is using an unknown algorithm")
expected_signature = hmac.new(application_secret_key.encode('utf-8'), msg=encoded_payload.encode('utf-8'),
digestmod=hashlib.sha256).digest()
if signature != expected_signature:
raise SignedRequestError("Signed request signature mismatch")
return signed_request_data
|
[
"def",
"parse",
"(",
"cls",
",",
"signed_request",
",",
"application_secret_key",
")",
":",
"def",
"decode",
"(",
"encoded",
")",
":",
"padding",
"=",
"'='",
"*",
"(",
"len",
"(",
"encoded",
")",
"%",
"4",
")",
"return",
"base64",
".",
"urlsafe_b64decode",
"(",
"encoded",
"+",
"padding",
")",
"try",
":",
"encoded_signature",
",",
"encoded_payload",
"=",
"(",
"str",
"(",
"string",
")",
"for",
"string",
"in",
"signed_request",
".",
"split",
"(",
"'.'",
",",
"2",
")",
")",
"signature",
"=",
"decode",
"(",
"encoded_signature",
")",
"signed_request_data",
"=",
"json",
".",
"loads",
"(",
"decode",
"(",
"encoded_payload",
")",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"raise",
"SignedRequestError",
"(",
"\"Signed request had a corrupt payload\"",
")",
"if",
"signed_request_data",
".",
"get",
"(",
"'algorithm'",
",",
"''",
")",
".",
"upper",
"(",
")",
"!=",
"'HMAC-SHA256'",
":",
"raise",
"SignedRequestError",
"(",
"\"Signed request is using an unknown algorithm\"",
")",
"expected_signature",
"=",
"hmac",
".",
"new",
"(",
"application_secret_key",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"msg",
"=",
"encoded_payload",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"digestmod",
"=",
"hashlib",
".",
"sha256",
")",
".",
"digest",
"(",
")",
"if",
"signature",
"!=",
"expected_signature",
":",
"raise",
"SignedRequestError",
"(",
"\"Signed request signature mismatch\"",
")",
"return",
"signed_request_data"
] |
Parse a signed request, returning a dictionary describing its payload.
|
[
"Parse",
"a",
"signed",
"request",
"returning",
"a",
"dictionary",
"describing",
"its",
"payload",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/signed_request.py#L92-L113
|
15,775
|
jgorset/facepy
|
facepy/signed_request.py
|
SignedRequest.generate
|
def generate(self):
"""Generate a signed request from this instance."""
payload = {
'algorithm': 'HMAC-SHA256'
}
if self.data:
payload['app_data'] = self.data
if self.page:
payload['page'] = {}
if self.page.id:
payload['page']['id'] = self.page.id
if self.page.is_liked:
payload['page']['liked'] = self.page.is_liked
if self.page.is_admin:
payload['page']['admin'] = self.page.is_admin
if self.user:
payload['user'] = {}
if self.user.country:
payload['user']['country'] = self.user.country
if self.user.locale:
payload['user']['locale'] = self.user.locale
if self.user.age:
payload['user']['age'] = {
'min': self.user.age[0],
'max': self.user.age[-1]
}
if self.user.oauth_token:
if self.user.oauth_token.token:
payload['oauth_token'] = self.user.oauth_token.token
if self.user.oauth_token.expires_at is None:
payload['expires_in'] = 0
else:
payload['expires_in'] = int(time.mktime(self.user.oauth_token.expires_at.timetuple()))
if self.user.oauth_token.issued_at:
payload['issued_at'] = int(time.mktime(self.user.oauth_token.issued_at.timetuple()))
if self.user.id:
payload['user_id'] = self.user.id
encoded_payload = base64.urlsafe_b64encode(
json.dumps(payload, separators=(',', ':')).encode('utf-8')
)
encoded_signature = base64.urlsafe_b64encode(hmac.new(
self.application_secret_key.encode('utf-8'),
encoded_payload,
hashlib.sha256
).digest())
return '%(signature)s.%(payload)s' % {
'signature': encoded_signature,
'payload': encoded_payload
}
|
python
|
def generate(self):
"""Generate a signed request from this instance."""
payload = {
'algorithm': 'HMAC-SHA256'
}
if self.data:
payload['app_data'] = self.data
if self.page:
payload['page'] = {}
if self.page.id:
payload['page']['id'] = self.page.id
if self.page.is_liked:
payload['page']['liked'] = self.page.is_liked
if self.page.is_admin:
payload['page']['admin'] = self.page.is_admin
if self.user:
payload['user'] = {}
if self.user.country:
payload['user']['country'] = self.user.country
if self.user.locale:
payload['user']['locale'] = self.user.locale
if self.user.age:
payload['user']['age'] = {
'min': self.user.age[0],
'max': self.user.age[-1]
}
if self.user.oauth_token:
if self.user.oauth_token.token:
payload['oauth_token'] = self.user.oauth_token.token
if self.user.oauth_token.expires_at is None:
payload['expires_in'] = 0
else:
payload['expires_in'] = int(time.mktime(self.user.oauth_token.expires_at.timetuple()))
if self.user.oauth_token.issued_at:
payload['issued_at'] = int(time.mktime(self.user.oauth_token.issued_at.timetuple()))
if self.user.id:
payload['user_id'] = self.user.id
encoded_payload = base64.urlsafe_b64encode(
json.dumps(payload, separators=(',', ':')).encode('utf-8')
)
encoded_signature = base64.urlsafe_b64encode(hmac.new(
self.application_secret_key.encode('utf-8'),
encoded_payload,
hashlib.sha256
).digest())
return '%(signature)s.%(payload)s' % {
'signature': encoded_signature,
'payload': encoded_payload
}
|
[
"def",
"generate",
"(",
"self",
")",
":",
"payload",
"=",
"{",
"'algorithm'",
":",
"'HMAC-SHA256'",
"}",
"if",
"self",
".",
"data",
":",
"payload",
"[",
"'app_data'",
"]",
"=",
"self",
".",
"data",
"if",
"self",
".",
"page",
":",
"payload",
"[",
"'page'",
"]",
"=",
"{",
"}",
"if",
"self",
".",
"page",
".",
"id",
":",
"payload",
"[",
"'page'",
"]",
"[",
"'id'",
"]",
"=",
"self",
".",
"page",
".",
"id",
"if",
"self",
".",
"page",
".",
"is_liked",
":",
"payload",
"[",
"'page'",
"]",
"[",
"'liked'",
"]",
"=",
"self",
".",
"page",
".",
"is_liked",
"if",
"self",
".",
"page",
".",
"is_admin",
":",
"payload",
"[",
"'page'",
"]",
"[",
"'admin'",
"]",
"=",
"self",
".",
"page",
".",
"is_admin",
"if",
"self",
".",
"user",
":",
"payload",
"[",
"'user'",
"]",
"=",
"{",
"}",
"if",
"self",
".",
"user",
".",
"country",
":",
"payload",
"[",
"'user'",
"]",
"[",
"'country'",
"]",
"=",
"self",
".",
"user",
".",
"country",
"if",
"self",
".",
"user",
".",
"locale",
":",
"payload",
"[",
"'user'",
"]",
"[",
"'locale'",
"]",
"=",
"self",
".",
"user",
".",
"locale",
"if",
"self",
".",
"user",
".",
"age",
":",
"payload",
"[",
"'user'",
"]",
"[",
"'age'",
"]",
"=",
"{",
"'min'",
":",
"self",
".",
"user",
".",
"age",
"[",
"0",
"]",
",",
"'max'",
":",
"self",
".",
"user",
".",
"age",
"[",
"-",
"1",
"]",
"}",
"if",
"self",
".",
"user",
".",
"oauth_token",
":",
"if",
"self",
".",
"user",
".",
"oauth_token",
".",
"token",
":",
"payload",
"[",
"'oauth_token'",
"]",
"=",
"self",
".",
"user",
".",
"oauth_token",
".",
"token",
"if",
"self",
".",
"user",
".",
"oauth_token",
".",
"expires_at",
"is",
"None",
":",
"payload",
"[",
"'expires_in'",
"]",
"=",
"0",
"else",
":",
"payload",
"[",
"'expires_in'",
"]",
"=",
"int",
"(",
"time",
".",
"mktime",
"(",
"self",
".",
"user",
".",
"oauth_token",
".",
"expires_at",
".",
"timetuple",
"(",
")",
")",
")",
"if",
"self",
".",
"user",
".",
"oauth_token",
".",
"issued_at",
":",
"payload",
"[",
"'issued_at'",
"]",
"=",
"int",
"(",
"time",
".",
"mktime",
"(",
"self",
".",
"user",
".",
"oauth_token",
".",
"issued_at",
".",
"timetuple",
"(",
")",
")",
")",
"if",
"self",
".",
"user",
".",
"id",
":",
"payload",
"[",
"'user_id'",
"]",
"=",
"self",
".",
"user",
".",
"id",
"encoded_payload",
"=",
"base64",
".",
"urlsafe_b64encode",
"(",
"json",
".",
"dumps",
"(",
"payload",
",",
"separators",
"=",
"(",
"','",
",",
"':'",
")",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"encoded_signature",
"=",
"base64",
".",
"urlsafe_b64encode",
"(",
"hmac",
".",
"new",
"(",
"self",
".",
"application_secret_key",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"encoded_payload",
",",
"hashlib",
".",
"sha256",
")",
".",
"digest",
"(",
")",
")",
"return",
"'%(signature)s.%(payload)s'",
"%",
"{",
"'signature'",
":",
"encoded_signature",
",",
"'payload'",
":",
"encoded_payload",
"}"
] |
Generate a signed request from this instance.
|
[
"Generate",
"a",
"signed",
"request",
"from",
"this",
"instance",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/signed_request.py#L117-L182
|
15,776
|
jgorset/facepy
|
facepy/graph_api.py
|
GraphAPI.for_application
|
def for_application(self, id, secret_key, api_version=None):
"""
Initialize GraphAPI with an OAuth access token for an application.
:param id: An integer describing a Facebook application.
:param secret_key: A String describing the Facebook application's secret key.
"""
from facepy.utils import get_application_access_token
access_token = get_application_access_token(id, secret_key, api_version=api_version)
return GraphAPI(access_token, version=api_version)
|
python
|
def for_application(self, id, secret_key, api_version=None):
"""
Initialize GraphAPI with an OAuth access token for an application.
:param id: An integer describing a Facebook application.
:param secret_key: A String describing the Facebook application's secret key.
"""
from facepy.utils import get_application_access_token
access_token = get_application_access_token(id, secret_key, api_version=api_version)
return GraphAPI(access_token, version=api_version)
|
[
"def",
"for_application",
"(",
"self",
",",
"id",
",",
"secret_key",
",",
"api_version",
"=",
"None",
")",
":",
"from",
"facepy",
".",
"utils",
"import",
"get_application_access_token",
"access_token",
"=",
"get_application_access_token",
"(",
"id",
",",
"secret_key",
",",
"api_version",
"=",
"api_version",
")",
"return",
"GraphAPI",
"(",
"access_token",
",",
"version",
"=",
"api_version",
")"
] |
Initialize GraphAPI with an OAuth access token for an application.
:param id: An integer describing a Facebook application.
:param secret_key: A String describing the Facebook application's secret key.
|
[
"Initialize",
"GraphAPI",
"with",
"an",
"OAuth",
"access",
"token",
"for",
"an",
"application",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L43-L53
|
15,777
|
jgorset/facepy
|
facepy/graph_api.py
|
GraphAPI.get
|
def get(self, path='', page=False, retry=3, **options):
"""
Get an item from the Graph API.
:param path: A string describing the path to the item.
:param page: A boolean describing whether to return a generator that
iterates over each page of results.
:param retry: An integer describing how many times the request may be retried.
:param options: Graph API parameters such as 'limit', 'offset' or 'since'.
Floating-point numbers will be returned as :class:`decimal.Decimal`
instances.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of parameters.
"""
response = self._query(
method='GET',
path=path,
data=options,
page=page,
retry=retry
)
if response is False:
raise FacebookError('Could not get "%s".' % path)
return response
|
python
|
def get(self, path='', page=False, retry=3, **options):
"""
Get an item from the Graph API.
:param path: A string describing the path to the item.
:param page: A boolean describing whether to return a generator that
iterates over each page of results.
:param retry: An integer describing how many times the request may be retried.
:param options: Graph API parameters such as 'limit', 'offset' or 'since'.
Floating-point numbers will be returned as :class:`decimal.Decimal`
instances.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of parameters.
"""
response = self._query(
method='GET',
path=path,
data=options,
page=page,
retry=retry
)
if response is False:
raise FacebookError('Could not get "%s".' % path)
return response
|
[
"def",
"get",
"(",
"self",
",",
"path",
"=",
"''",
",",
"page",
"=",
"False",
",",
"retry",
"=",
"3",
",",
"*",
"*",
"options",
")",
":",
"response",
"=",
"self",
".",
"_query",
"(",
"method",
"=",
"'GET'",
",",
"path",
"=",
"path",
",",
"data",
"=",
"options",
",",
"page",
"=",
"page",
",",
"retry",
"=",
"retry",
")",
"if",
"response",
"is",
"False",
":",
"raise",
"FacebookError",
"(",
"'Could not get \"%s\".'",
"%",
"path",
")",
"return",
"response"
] |
Get an item from the Graph API.
:param path: A string describing the path to the item.
:param page: A boolean describing whether to return a generator that
iterates over each page of results.
:param retry: An integer describing how many times the request may be retried.
:param options: Graph API parameters such as 'limit', 'offset' or 'since'.
Floating-point numbers will be returned as :class:`decimal.Decimal`
instances.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of parameters.
|
[
"Get",
"an",
"item",
"from",
"the",
"Graph",
"API",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L55-L82
|
15,778
|
jgorset/facepy
|
facepy/graph_api.py
|
GraphAPI.post
|
def post(self, path='', retry=0, **data):
"""
Post an item to the Graph API.
:param path: A string describing the path to the item.
:param retry: An integer describing how many times the request may be retried.
:param data: Graph API parameters such as 'message' or 'source'.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of options.
"""
response = self._query(
method='POST',
path=path,
data=data,
retry=retry
)
if response is False:
raise FacebookError('Could not post to "%s"' % path)
return response
|
python
|
def post(self, path='', retry=0, **data):
"""
Post an item to the Graph API.
:param path: A string describing the path to the item.
:param retry: An integer describing how many times the request may be retried.
:param data: Graph API parameters such as 'message' or 'source'.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of options.
"""
response = self._query(
method='POST',
path=path,
data=data,
retry=retry
)
if response is False:
raise FacebookError('Could not post to "%s"' % path)
return response
|
[
"def",
"post",
"(",
"self",
",",
"path",
"=",
"''",
",",
"retry",
"=",
"0",
",",
"*",
"*",
"data",
")",
":",
"response",
"=",
"self",
".",
"_query",
"(",
"method",
"=",
"'POST'",
",",
"path",
"=",
"path",
",",
"data",
"=",
"data",
",",
"retry",
"=",
"retry",
")",
"if",
"response",
"is",
"False",
":",
"raise",
"FacebookError",
"(",
"'Could not post to \"%s\"'",
"%",
"path",
")",
"return",
"response"
] |
Post an item to the Graph API.
:param path: A string describing the path to the item.
:param retry: An integer describing how many times the request may be retried.
:param data: Graph API parameters such as 'message' or 'source'.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of options.
|
[
"Post",
"an",
"item",
"to",
"the",
"Graph",
"API",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L84-L105
|
15,779
|
jgorset/facepy
|
facepy/graph_api.py
|
GraphAPI.search
|
def search(self, term, type='place', page=False, retry=3, **options):
"""
Search for an item in the Graph API.
:param term: A string describing the search term.
:param type: A string describing the type of items to search for.
:param page: A boolean describing whether to return a generator that
iterates over each page of results.
:param retry: An integer describing how many times the request may be retried.
:param options: Graph API parameters, such as 'center' and 'distance'.
Supported types are only ``place`` since Graph API 2.0.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of options.
"""
if type != 'place':
raise ValueError('Unsupported type "%s". The only supported type is "place" since Graph API 2.0.' % type)
options = dict({
'q': term,
'type': type,
}, **options)
response = self._query('GET', 'search', options, page, retry)
return response
|
python
|
def search(self, term, type='place', page=False, retry=3, **options):
"""
Search for an item in the Graph API.
:param term: A string describing the search term.
:param type: A string describing the type of items to search for.
:param page: A boolean describing whether to return a generator that
iterates over each page of results.
:param retry: An integer describing how many times the request may be retried.
:param options: Graph API parameters, such as 'center' and 'distance'.
Supported types are only ``place`` since Graph API 2.0.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of options.
"""
if type != 'place':
raise ValueError('Unsupported type "%s". The only supported type is "place" since Graph API 2.0.' % type)
options = dict({
'q': term,
'type': type,
}, **options)
response = self._query('GET', 'search', options, page, retry)
return response
|
[
"def",
"search",
"(",
"self",
",",
"term",
",",
"type",
"=",
"'place'",
",",
"page",
"=",
"False",
",",
"retry",
"=",
"3",
",",
"*",
"*",
"options",
")",
":",
"if",
"type",
"!=",
"'place'",
":",
"raise",
"ValueError",
"(",
"'Unsupported type \"%s\". The only supported type is \"place\" since Graph API 2.0.'",
"%",
"type",
")",
"options",
"=",
"dict",
"(",
"{",
"'q'",
":",
"term",
",",
"'type'",
":",
"type",
",",
"}",
",",
"*",
"*",
"options",
")",
"response",
"=",
"self",
".",
"_query",
"(",
"'GET'",
",",
"'search'",
",",
"options",
",",
"page",
",",
"retry",
")",
"return",
"response"
] |
Search for an item in the Graph API.
:param term: A string describing the search term.
:param type: A string describing the type of items to search for.
:param page: A boolean describing whether to return a generator that
iterates over each page of results.
:param retry: An integer describing how many times the request may be retried.
:param options: Graph API parameters, such as 'center' and 'distance'.
Supported types are only ``place`` since Graph API 2.0.
See `Facebook's Graph API documentation <http://developers.facebook.com/docs/reference/api/>`_
for an exhaustive list of options.
|
[
"Search",
"for",
"an",
"item",
"in",
"the",
"Graph",
"API",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L130-L157
|
15,780
|
jgorset/facepy
|
facepy/graph_api.py
|
GraphAPI.batch
|
def batch(self, requests):
"""
Make a batch request.
:param requests: A list of dictionaries with keys 'method', 'relative_url' and optionally 'body'.
Yields a list of responses and/or exceptions.
"""
for request in requests:
if 'body' in request:
request['body'] = urlencode(request['body'])
def _grouper(complete_list, n=1):
"""
Batches a list into constant size chunks.
:param complete_list: A input list (not a generator).
:param n: The size of the chunk.
Adapted from <http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python>
"""
for i in range(0, len(complete_list), n):
yield complete_list[i:i + n]
responses = []
# Maximum batch size for Facebook is 50 so split up requests
# https://developers.facebook.com/docs/graph-api/making-multiple-requests/#limits
for group in _grouper(requests, 50):
responses += self.post(
batch=json.dumps(group)
)
for response, request in zip(responses, requests):
# Facilitate for empty Graph API responses.
#
# https://github.com/jgorset/facepy/pull/30
if not response:
yield None
continue
try:
yield self._parse(response['body'])
except FacepyError as exception:
exception.request = request
yield exception
|
python
|
def batch(self, requests):
"""
Make a batch request.
:param requests: A list of dictionaries with keys 'method', 'relative_url' and optionally 'body'.
Yields a list of responses and/or exceptions.
"""
for request in requests:
if 'body' in request:
request['body'] = urlencode(request['body'])
def _grouper(complete_list, n=1):
"""
Batches a list into constant size chunks.
:param complete_list: A input list (not a generator).
:param n: The size of the chunk.
Adapted from <http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python>
"""
for i in range(0, len(complete_list), n):
yield complete_list[i:i + n]
responses = []
# Maximum batch size for Facebook is 50 so split up requests
# https://developers.facebook.com/docs/graph-api/making-multiple-requests/#limits
for group in _grouper(requests, 50):
responses += self.post(
batch=json.dumps(group)
)
for response, request in zip(responses, requests):
# Facilitate for empty Graph API responses.
#
# https://github.com/jgorset/facepy/pull/30
if not response:
yield None
continue
try:
yield self._parse(response['body'])
except FacepyError as exception:
exception.request = request
yield exception
|
[
"def",
"batch",
"(",
"self",
",",
"requests",
")",
":",
"for",
"request",
"in",
"requests",
":",
"if",
"'body'",
"in",
"request",
":",
"request",
"[",
"'body'",
"]",
"=",
"urlencode",
"(",
"request",
"[",
"'body'",
"]",
")",
"def",
"_grouper",
"(",
"complete_list",
",",
"n",
"=",
"1",
")",
":",
"\"\"\"\n Batches a list into constant size chunks.\n\n :param complete_list: A input list (not a generator).\n :param n: The size of the chunk.\n\n Adapted from <http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python>\n \"\"\"",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"complete_list",
")",
",",
"n",
")",
":",
"yield",
"complete_list",
"[",
"i",
":",
"i",
"+",
"n",
"]",
"responses",
"=",
"[",
"]",
"# Maximum batch size for Facebook is 50 so split up requests",
"# https://developers.facebook.com/docs/graph-api/making-multiple-requests/#limits",
"for",
"group",
"in",
"_grouper",
"(",
"requests",
",",
"50",
")",
":",
"responses",
"+=",
"self",
".",
"post",
"(",
"batch",
"=",
"json",
".",
"dumps",
"(",
"group",
")",
")",
"for",
"response",
",",
"request",
"in",
"zip",
"(",
"responses",
",",
"requests",
")",
":",
"# Facilitate for empty Graph API responses.",
"#",
"# https://github.com/jgorset/facepy/pull/30",
"if",
"not",
"response",
":",
"yield",
"None",
"continue",
"try",
":",
"yield",
"self",
".",
"_parse",
"(",
"response",
"[",
"'body'",
"]",
")",
"except",
"FacepyError",
"as",
"exception",
":",
"exception",
".",
"request",
"=",
"request",
"yield",
"exception"
] |
Make a batch request.
:param requests: A list of dictionaries with keys 'method', 'relative_url' and optionally 'body'.
Yields a list of responses and/or exceptions.
|
[
"Make",
"a",
"batch",
"request",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L159-L207
|
15,781
|
jgorset/facepy
|
facepy/graph_api.py
|
GraphAPI._parse
|
def _parse(self, data):
"""
Parse the response from Facebook's Graph API.
:param data: A string describing the Graph API's response.
"""
if type(data) == type(bytes()):
try:
data = data.decode('utf-8')
except UnicodeDecodeError:
return data
try:
data = json.loads(data, parse_float=Decimal)
except ValueError:
return data
# Facebook's Graph API sometimes responds with 'true' or 'false'. Facebook offers no documentation
# as to the prerequisites for this type of response, though it seems that it responds with 'true'
# when objects are successfully deleted and 'false' upon attempting to delete or access an item that
# one does not have access to.
#
# For example, the API would respond with 'false' upon attempting to query a feed item without having
# the 'read_stream' extended permission. If you were to query the entire feed, however, it would respond
# with an empty list instead.
#
# Genius.
#
# We'll handle this discrepancy as gracefully as we can by implementing logic to deal with this behavior
# in the high-level access functions (get, post, delete etc.).
if type(data) is dict:
if 'error' in data:
error = data['error']
if error.get('type') == "OAuthException":
exception = OAuthError
else:
exception = FacebookError
raise exception(**self._get_error_params(data))
# Facebook occasionally reports errors in its legacy error format.
if 'error_msg' in data:
raise FacebookError(**self._get_error_params(data))
return data
|
python
|
def _parse(self, data):
"""
Parse the response from Facebook's Graph API.
:param data: A string describing the Graph API's response.
"""
if type(data) == type(bytes()):
try:
data = data.decode('utf-8')
except UnicodeDecodeError:
return data
try:
data = json.loads(data, parse_float=Decimal)
except ValueError:
return data
# Facebook's Graph API sometimes responds with 'true' or 'false'. Facebook offers no documentation
# as to the prerequisites for this type of response, though it seems that it responds with 'true'
# when objects are successfully deleted and 'false' upon attempting to delete or access an item that
# one does not have access to.
#
# For example, the API would respond with 'false' upon attempting to query a feed item without having
# the 'read_stream' extended permission. If you were to query the entire feed, however, it would respond
# with an empty list instead.
#
# Genius.
#
# We'll handle this discrepancy as gracefully as we can by implementing logic to deal with this behavior
# in the high-level access functions (get, post, delete etc.).
if type(data) is dict:
if 'error' in data:
error = data['error']
if error.get('type') == "OAuthException":
exception = OAuthError
else:
exception = FacebookError
raise exception(**self._get_error_params(data))
# Facebook occasionally reports errors in its legacy error format.
if 'error_msg' in data:
raise FacebookError(**self._get_error_params(data))
return data
|
[
"def",
"_parse",
"(",
"self",
",",
"data",
")",
":",
"if",
"type",
"(",
"data",
")",
"==",
"type",
"(",
"bytes",
"(",
")",
")",
":",
"try",
":",
"data",
"=",
"data",
".",
"decode",
"(",
"'utf-8'",
")",
"except",
"UnicodeDecodeError",
":",
"return",
"data",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"data",
",",
"parse_float",
"=",
"Decimal",
")",
"except",
"ValueError",
":",
"return",
"data",
"# Facebook's Graph API sometimes responds with 'true' or 'false'. Facebook offers no documentation",
"# as to the prerequisites for this type of response, though it seems that it responds with 'true'",
"# when objects are successfully deleted and 'false' upon attempting to delete or access an item that",
"# one does not have access to.",
"#",
"# For example, the API would respond with 'false' upon attempting to query a feed item without having",
"# the 'read_stream' extended permission. If you were to query the entire feed, however, it would respond",
"# with an empty list instead.",
"#",
"# Genius.",
"#",
"# We'll handle this discrepancy as gracefully as we can by implementing logic to deal with this behavior",
"# in the high-level access functions (get, post, delete etc.).",
"if",
"type",
"(",
"data",
")",
"is",
"dict",
":",
"if",
"'error'",
"in",
"data",
":",
"error",
"=",
"data",
"[",
"'error'",
"]",
"if",
"error",
".",
"get",
"(",
"'type'",
")",
"==",
"\"OAuthException\"",
":",
"exception",
"=",
"OAuthError",
"else",
":",
"exception",
"=",
"FacebookError",
"raise",
"exception",
"(",
"*",
"*",
"self",
".",
"_get_error_params",
"(",
"data",
")",
")",
"# Facebook occasionally reports errors in its legacy error format.",
"if",
"'error_msg'",
"in",
"data",
":",
"raise",
"FacebookError",
"(",
"*",
"*",
"self",
".",
"_get_error_params",
"(",
"data",
")",
")",
"return",
"data"
] |
Parse the response from Facebook's Graph API.
:param data: A string describing the Graph API's response.
|
[
"Parse",
"the",
"response",
"from",
"Facebook",
"s",
"Graph",
"API",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L372-L417
|
15,782
|
jgorset/facepy
|
facepy/utils.py
|
get_extended_access_token
|
def get_extended_access_token(access_token, application_id, application_secret_key, api_version=None):
"""
Get an extended OAuth access token.
:param access_token: A string describing an OAuth access token.
:param application_id: An integer describing the Facebook application's ID.
:param application_secret_key: A string describing the Facebook application's secret key.
Returns a tuple with a string describing the extended access token and a datetime instance
describing when it expires.
"""
graph = GraphAPI(version=api_version)
response = graph.get(
path='oauth/access_token',
client_id=application_id,
client_secret=application_secret_key,
grant_type='fb_exchange_token',
fb_exchange_token=access_token
)
try:
components = parse_qs(response)
except AttributeError: # api_version >= 2.3 returns a dict
return response['access_token'], None
token = components['access_token'][0]
try:
expires_at = datetime.now() + timedelta(seconds=int(components['expires'][0]))
except KeyError: # there is no expiration
expires_at = None
return token, expires_at
|
python
|
def get_extended_access_token(access_token, application_id, application_secret_key, api_version=None):
"""
Get an extended OAuth access token.
:param access_token: A string describing an OAuth access token.
:param application_id: An integer describing the Facebook application's ID.
:param application_secret_key: A string describing the Facebook application's secret key.
Returns a tuple with a string describing the extended access token and a datetime instance
describing when it expires.
"""
graph = GraphAPI(version=api_version)
response = graph.get(
path='oauth/access_token',
client_id=application_id,
client_secret=application_secret_key,
grant_type='fb_exchange_token',
fb_exchange_token=access_token
)
try:
components = parse_qs(response)
except AttributeError: # api_version >= 2.3 returns a dict
return response['access_token'], None
token = components['access_token'][0]
try:
expires_at = datetime.now() + timedelta(seconds=int(components['expires'][0]))
except KeyError: # there is no expiration
expires_at = None
return token, expires_at
|
[
"def",
"get_extended_access_token",
"(",
"access_token",
",",
"application_id",
",",
"application_secret_key",
",",
"api_version",
"=",
"None",
")",
":",
"graph",
"=",
"GraphAPI",
"(",
"version",
"=",
"api_version",
")",
"response",
"=",
"graph",
".",
"get",
"(",
"path",
"=",
"'oauth/access_token'",
",",
"client_id",
"=",
"application_id",
",",
"client_secret",
"=",
"application_secret_key",
",",
"grant_type",
"=",
"'fb_exchange_token'",
",",
"fb_exchange_token",
"=",
"access_token",
")",
"try",
":",
"components",
"=",
"parse_qs",
"(",
"response",
")",
"except",
"AttributeError",
":",
"# api_version >= 2.3 returns a dict",
"return",
"response",
"[",
"'access_token'",
"]",
",",
"None",
"token",
"=",
"components",
"[",
"'access_token'",
"]",
"[",
"0",
"]",
"try",
":",
"expires_at",
"=",
"datetime",
".",
"now",
"(",
")",
"+",
"timedelta",
"(",
"seconds",
"=",
"int",
"(",
"components",
"[",
"'expires'",
"]",
"[",
"0",
"]",
")",
")",
"except",
"KeyError",
":",
"# there is no expiration",
"expires_at",
"=",
"None",
"return",
"token",
",",
"expires_at"
] |
Get an extended OAuth access token.
:param access_token: A string describing an OAuth access token.
:param application_id: An integer describing the Facebook application's ID.
:param application_secret_key: A string describing the Facebook application's secret key.
Returns a tuple with a string describing the extended access token and a datetime instance
describing when it expires.
|
[
"Get",
"an",
"extended",
"OAuth",
"access",
"token",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/utils.py#L11-L44
|
15,783
|
jgorset/facepy
|
facepy/utils.py
|
get_application_access_token
|
def get_application_access_token(application_id, application_secret_key, api_version=None):
"""
Get an OAuth access token for the given application.
:param application_id: An integer describing a Facebook application's ID.
:param application_secret_key: A string describing a Facebook application's secret key.
"""
graph = GraphAPI(version=api_version)
response = graph.get(
path='oauth/access_token',
client_id=application_id,
client_secret=application_secret_key,
grant_type='client_credentials'
)
try:
data = parse_qs(response)
try:
return data['access_token'][0]
except KeyError:
raise GraphAPI.FacebookError('No access token given')
except AttributeError: # api_version >= 2.3 returns a dict
return response['access_token'], None
|
python
|
def get_application_access_token(application_id, application_secret_key, api_version=None):
"""
Get an OAuth access token for the given application.
:param application_id: An integer describing a Facebook application's ID.
:param application_secret_key: A string describing a Facebook application's secret key.
"""
graph = GraphAPI(version=api_version)
response = graph.get(
path='oauth/access_token',
client_id=application_id,
client_secret=application_secret_key,
grant_type='client_credentials'
)
try:
data = parse_qs(response)
try:
return data['access_token'][0]
except KeyError:
raise GraphAPI.FacebookError('No access token given')
except AttributeError: # api_version >= 2.3 returns a dict
return response['access_token'], None
|
[
"def",
"get_application_access_token",
"(",
"application_id",
",",
"application_secret_key",
",",
"api_version",
"=",
"None",
")",
":",
"graph",
"=",
"GraphAPI",
"(",
"version",
"=",
"api_version",
")",
"response",
"=",
"graph",
".",
"get",
"(",
"path",
"=",
"'oauth/access_token'",
",",
"client_id",
"=",
"application_id",
",",
"client_secret",
"=",
"application_secret_key",
",",
"grant_type",
"=",
"'client_credentials'",
")",
"try",
":",
"data",
"=",
"parse_qs",
"(",
"response",
")",
"try",
":",
"return",
"data",
"[",
"'access_token'",
"]",
"[",
"0",
"]",
"except",
"KeyError",
":",
"raise",
"GraphAPI",
".",
"FacebookError",
"(",
"'No access token given'",
")",
"except",
"AttributeError",
":",
"# api_version >= 2.3 returns a dict",
"return",
"response",
"[",
"'access_token'",
"]",
",",
"None"
] |
Get an OAuth access token for the given application.
:param application_id: An integer describing a Facebook application's ID.
:param application_secret_key: A string describing a Facebook application's secret key.
|
[
"Get",
"an",
"OAuth",
"access",
"token",
"for",
"the",
"given",
"application",
"."
] |
1be3ee21389fb2db543927a2f4ffa949faec4242
|
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/utils.py#L47-L71
|
15,784
|
ionelmc/python-redis-lock
|
src/redis_lock/django_cache.py
|
RedisCache.locked_get_or_set
|
def locked_get_or_set(self, key, value_creator, version=None,
expire=None, id=None, lock_key=None,
timeout=DEFAULT_TIMEOUT):
"""
Fetch a given key from the cache. If the key does not exist, the key is added and
set to the value returned when calling `value_creator`. The creator function
is invoked inside of a lock.
"""
if lock_key is None:
lock_key = 'get_or_set:' + key
val = self.get(key, version=version)
if val is not None:
return val
with self.lock(lock_key, expire=expire, id=id):
# Was the value set while we were trying to acquire the lock?
val = self.get(key, version=version)
if val is not None:
return val
# Nope, create value now.
val = value_creator()
if val is None:
raise ValueError('`value_creator` must return a value')
self.set(key, val, timeout=timeout, version=version)
return val
|
python
|
def locked_get_or_set(self, key, value_creator, version=None,
expire=None, id=None, lock_key=None,
timeout=DEFAULT_TIMEOUT):
"""
Fetch a given key from the cache. If the key does not exist, the key is added and
set to the value returned when calling `value_creator`. The creator function
is invoked inside of a lock.
"""
if lock_key is None:
lock_key = 'get_or_set:' + key
val = self.get(key, version=version)
if val is not None:
return val
with self.lock(lock_key, expire=expire, id=id):
# Was the value set while we were trying to acquire the lock?
val = self.get(key, version=version)
if val is not None:
return val
# Nope, create value now.
val = value_creator()
if val is None:
raise ValueError('`value_creator` must return a value')
self.set(key, val, timeout=timeout, version=version)
return val
|
[
"def",
"locked_get_or_set",
"(",
"self",
",",
"key",
",",
"value_creator",
",",
"version",
"=",
"None",
",",
"expire",
"=",
"None",
",",
"id",
"=",
"None",
",",
"lock_key",
"=",
"None",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
":",
"if",
"lock_key",
"is",
"None",
":",
"lock_key",
"=",
"'get_or_set:'",
"+",
"key",
"val",
"=",
"self",
".",
"get",
"(",
"key",
",",
"version",
"=",
"version",
")",
"if",
"val",
"is",
"not",
"None",
":",
"return",
"val",
"with",
"self",
".",
"lock",
"(",
"lock_key",
",",
"expire",
"=",
"expire",
",",
"id",
"=",
"id",
")",
":",
"# Was the value set while we were trying to acquire the lock?",
"val",
"=",
"self",
".",
"get",
"(",
"key",
",",
"version",
"=",
"version",
")",
"if",
"val",
"is",
"not",
"None",
":",
"return",
"val",
"# Nope, create value now.",
"val",
"=",
"value_creator",
"(",
")",
"if",
"val",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'`value_creator` must return a value'",
")",
"self",
".",
"set",
"(",
"key",
",",
"val",
",",
"timeout",
"=",
"timeout",
",",
"version",
"=",
"version",
")",
"return",
"val"
] |
Fetch a given key from the cache. If the key does not exist, the key is added and
set to the value returned when calling `value_creator`. The creator function
is invoked inside of a lock.
|
[
"Fetch",
"a",
"given",
"key",
"from",
"the",
"cache",
".",
"If",
"the",
"key",
"does",
"not",
"exist",
"the",
"key",
"is",
"added",
"and",
"set",
"to",
"the",
"value",
"returned",
"when",
"calling",
"value_creator",
".",
"The",
"creator",
"function",
"is",
"invoked",
"inside",
"of",
"a",
"lock",
"."
] |
5481cd88b64d86d318e389c79b0575a73464b1f5
|
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/django_cache.py#L23-L51
|
15,785
|
ionelmc/python-redis-lock
|
src/redis_lock/__init__.py
|
_eval_script
|
def _eval_script(redis, script_id, *keys, **kwargs):
"""Tries to call ``EVALSHA`` with the `hash` and then, if it fails, calls
regular ``EVAL`` with the `script`.
"""
args = kwargs.pop('args', ())
if kwargs:
raise TypeError("Unexpected keyword arguments %s" % kwargs.keys())
try:
return redis.evalsha(SCRIPTS[script_id], len(keys), *keys + args)
except NoScriptError:
logger.info("%s not cached.", SCRIPTS[script_id + 2])
return redis.eval(SCRIPTS[script_id + 1], len(keys), *keys + args)
|
python
|
def _eval_script(redis, script_id, *keys, **kwargs):
"""Tries to call ``EVALSHA`` with the `hash` and then, if it fails, calls
regular ``EVAL`` with the `script`.
"""
args = kwargs.pop('args', ())
if kwargs:
raise TypeError("Unexpected keyword arguments %s" % kwargs.keys())
try:
return redis.evalsha(SCRIPTS[script_id], len(keys), *keys + args)
except NoScriptError:
logger.info("%s not cached.", SCRIPTS[script_id + 2])
return redis.eval(SCRIPTS[script_id + 1], len(keys), *keys + args)
|
[
"def",
"_eval_script",
"(",
"redis",
",",
"script_id",
",",
"*",
"keys",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"kwargs",
".",
"pop",
"(",
"'args'",
",",
"(",
")",
")",
"if",
"kwargs",
":",
"raise",
"TypeError",
"(",
"\"Unexpected keyword arguments %s\"",
"%",
"kwargs",
".",
"keys",
"(",
")",
")",
"try",
":",
"return",
"redis",
".",
"evalsha",
"(",
"SCRIPTS",
"[",
"script_id",
"]",
",",
"len",
"(",
"keys",
")",
",",
"*",
"keys",
"+",
"args",
")",
"except",
"NoScriptError",
":",
"logger",
".",
"info",
"(",
"\"%s not cached.\"",
",",
"SCRIPTS",
"[",
"script_id",
"+",
"2",
"]",
")",
"return",
"redis",
".",
"eval",
"(",
"SCRIPTS",
"[",
"script_id",
"+",
"1",
"]",
",",
"len",
"(",
"keys",
")",
",",
"*",
"keys",
"+",
"args",
")"
] |
Tries to call ``EVALSHA`` with the `hash` and then, if it fails, calls
regular ``EVAL`` with the `script`.
|
[
"Tries",
"to",
"call",
"EVALSHA",
"with",
"the",
"hash",
"and",
"then",
"if",
"it",
"fails",
"calls",
"regular",
"EVAL",
"with",
"the",
"script",
"."
] |
5481cd88b64d86d318e389c79b0575a73464b1f5
|
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L129-L140
|
15,786
|
ionelmc/python-redis-lock
|
src/redis_lock/__init__.py
|
Lock.reset
|
def reset(self):
"""
Forcibly deletes the lock. Use this with care.
"""
_eval_script(self._client, RESET, self._name, self._signal)
self._delete_signal()
|
python
|
def reset(self):
"""
Forcibly deletes the lock. Use this with care.
"""
_eval_script(self._client, RESET, self._name, self._signal)
self._delete_signal()
|
[
"def",
"reset",
"(",
"self",
")",
":",
"_eval_script",
"(",
"self",
".",
"_client",
",",
"RESET",
",",
"self",
".",
"_name",
",",
"self",
".",
"_signal",
")",
"self",
".",
"_delete_signal",
"(",
")"
] |
Forcibly deletes the lock. Use this with care.
|
[
"Forcibly",
"deletes",
"the",
"lock",
".",
"Use",
"this",
"with",
"care",
"."
] |
5481cd88b64d86d318e389c79b0575a73464b1f5
|
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L205-L210
|
15,787
|
ionelmc/python-redis-lock
|
src/redis_lock/__init__.py
|
Lock.extend
|
def extend(self, expire=None):
"""Extends expiration time of the lock.
:param expire:
New expiration time. If ``None`` - `expire` provided during
lock initialization will be taken.
"""
if expire is None:
if self._expire is not None:
expire = self._expire
else:
raise TypeError(
"To extend a lock 'expire' must be provided as an "
"argument to extend() method or at initialization time."
)
error = _eval_script(self._client, EXTEND, self._name, args=(expire, self._id))
if error == 1:
raise NotAcquired("Lock %s is not acquired or it already expired." % self._name)
elif error == 2:
raise NotExpirable("Lock %s has no assigned expiration time" %
self._name)
elif error:
raise RuntimeError("Unsupported error code %s from EXTEND script" % error)
|
python
|
def extend(self, expire=None):
"""Extends expiration time of the lock.
:param expire:
New expiration time. If ``None`` - `expire` provided during
lock initialization will be taken.
"""
if expire is None:
if self._expire is not None:
expire = self._expire
else:
raise TypeError(
"To extend a lock 'expire' must be provided as an "
"argument to extend() method or at initialization time."
)
error = _eval_script(self._client, EXTEND, self._name, args=(expire, self._id))
if error == 1:
raise NotAcquired("Lock %s is not acquired or it already expired." % self._name)
elif error == 2:
raise NotExpirable("Lock %s has no assigned expiration time" %
self._name)
elif error:
raise RuntimeError("Unsupported error code %s from EXTEND script" % error)
|
[
"def",
"extend",
"(",
"self",
",",
"expire",
"=",
"None",
")",
":",
"if",
"expire",
"is",
"None",
":",
"if",
"self",
".",
"_expire",
"is",
"not",
"None",
":",
"expire",
"=",
"self",
".",
"_expire",
"else",
":",
"raise",
"TypeError",
"(",
"\"To extend a lock 'expire' must be provided as an \"",
"\"argument to extend() method or at initialization time.\"",
")",
"error",
"=",
"_eval_script",
"(",
"self",
".",
"_client",
",",
"EXTEND",
",",
"self",
".",
"_name",
",",
"args",
"=",
"(",
"expire",
",",
"self",
".",
"_id",
")",
")",
"if",
"error",
"==",
"1",
":",
"raise",
"NotAcquired",
"(",
"\"Lock %s is not acquired or it already expired.\"",
"%",
"self",
".",
"_name",
")",
"elif",
"error",
"==",
"2",
":",
"raise",
"NotExpirable",
"(",
"\"Lock %s has no assigned expiration time\"",
"%",
"self",
".",
"_name",
")",
"elif",
"error",
":",
"raise",
"RuntimeError",
"(",
"\"Unsupported error code %s from EXTEND script\"",
"%",
"error",
")"
] |
Extends expiration time of the lock.
:param expire:
New expiration time. If ``None`` - `expire` provided during
lock initialization will be taken.
|
[
"Extends",
"expiration",
"time",
"of",
"the",
"lock",
"."
] |
5481cd88b64d86d318e389c79b0575a73464b1f5
|
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L263-L285
|
15,788
|
ionelmc/python-redis-lock
|
src/redis_lock/__init__.py
|
Lock._lock_renewer
|
def _lock_renewer(lockref, interval, stop):
"""
Renew the lock key in redis every `interval` seconds for as long
as `self._lock_renewal_thread.should_exit` is False.
"""
log = getLogger("%s.lock_refresher" % __name__)
while not stop.wait(timeout=interval):
log.debug("Refreshing lock")
lock = lockref()
if lock is None:
log.debug("The lock no longer exists, "
"stopping lock refreshing")
break
lock.extend(expire=lock._expire)
del lock
log.debug("Exit requested, stopping lock refreshing")
|
python
|
def _lock_renewer(lockref, interval, stop):
"""
Renew the lock key in redis every `interval` seconds for as long
as `self._lock_renewal_thread.should_exit` is False.
"""
log = getLogger("%s.lock_refresher" % __name__)
while not stop.wait(timeout=interval):
log.debug("Refreshing lock")
lock = lockref()
if lock is None:
log.debug("The lock no longer exists, "
"stopping lock refreshing")
break
lock.extend(expire=lock._expire)
del lock
log.debug("Exit requested, stopping lock refreshing")
|
[
"def",
"_lock_renewer",
"(",
"lockref",
",",
"interval",
",",
"stop",
")",
":",
"log",
"=",
"getLogger",
"(",
"\"%s.lock_refresher\"",
"%",
"__name__",
")",
"while",
"not",
"stop",
".",
"wait",
"(",
"timeout",
"=",
"interval",
")",
":",
"log",
".",
"debug",
"(",
"\"Refreshing lock\"",
")",
"lock",
"=",
"lockref",
"(",
")",
"if",
"lock",
"is",
"None",
":",
"log",
".",
"debug",
"(",
"\"The lock no longer exists, \"",
"\"stopping lock refreshing\"",
")",
"break",
"lock",
".",
"extend",
"(",
"expire",
"=",
"lock",
".",
"_expire",
")",
"del",
"lock",
"log",
".",
"debug",
"(",
"\"Exit requested, stopping lock refreshing\"",
")"
] |
Renew the lock key in redis every `interval` seconds for as long
as `self._lock_renewal_thread.should_exit` is False.
|
[
"Renew",
"the",
"lock",
"key",
"in",
"redis",
"every",
"interval",
"seconds",
"for",
"as",
"long",
"as",
"self",
".",
"_lock_renewal_thread",
".",
"should_exit",
"is",
"False",
"."
] |
5481cd88b64d86d318e389c79b0575a73464b1f5
|
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L288-L303
|
15,789
|
ionelmc/python-redis-lock
|
src/redis_lock/__init__.py
|
Lock._start_lock_renewer
|
def _start_lock_renewer(self):
"""
Starts the lock refresher thread.
"""
if self._lock_renewal_thread is not None:
raise AlreadyStarted("Lock refresh thread already started")
logger.debug(
"Starting thread to refresh lock every %s seconds",
self._lock_renewal_interval
)
self._lock_renewal_stop = threading.Event()
self._lock_renewal_thread = threading.Thread(
group=None,
target=self._lock_renewer,
kwargs={'lockref': weakref.ref(self),
'interval': self._lock_renewal_interval,
'stop': self._lock_renewal_stop}
)
self._lock_renewal_thread.setDaemon(True)
self._lock_renewal_thread.start()
|
python
|
def _start_lock_renewer(self):
"""
Starts the lock refresher thread.
"""
if self._lock_renewal_thread is not None:
raise AlreadyStarted("Lock refresh thread already started")
logger.debug(
"Starting thread to refresh lock every %s seconds",
self._lock_renewal_interval
)
self._lock_renewal_stop = threading.Event()
self._lock_renewal_thread = threading.Thread(
group=None,
target=self._lock_renewer,
kwargs={'lockref': weakref.ref(self),
'interval': self._lock_renewal_interval,
'stop': self._lock_renewal_stop}
)
self._lock_renewal_thread.setDaemon(True)
self._lock_renewal_thread.start()
|
[
"def",
"_start_lock_renewer",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lock_renewal_thread",
"is",
"not",
"None",
":",
"raise",
"AlreadyStarted",
"(",
"\"Lock refresh thread already started\"",
")",
"logger",
".",
"debug",
"(",
"\"Starting thread to refresh lock every %s seconds\"",
",",
"self",
".",
"_lock_renewal_interval",
")",
"self",
".",
"_lock_renewal_stop",
"=",
"threading",
".",
"Event",
"(",
")",
"self",
".",
"_lock_renewal_thread",
"=",
"threading",
".",
"Thread",
"(",
"group",
"=",
"None",
",",
"target",
"=",
"self",
".",
"_lock_renewer",
",",
"kwargs",
"=",
"{",
"'lockref'",
":",
"weakref",
".",
"ref",
"(",
"self",
")",
",",
"'interval'",
":",
"self",
".",
"_lock_renewal_interval",
",",
"'stop'",
":",
"self",
".",
"_lock_renewal_stop",
"}",
")",
"self",
".",
"_lock_renewal_thread",
".",
"setDaemon",
"(",
"True",
")",
"self",
".",
"_lock_renewal_thread",
".",
"start",
"(",
")"
] |
Starts the lock refresher thread.
|
[
"Starts",
"the",
"lock",
"refresher",
"thread",
"."
] |
5481cd88b64d86d318e389c79b0575a73464b1f5
|
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L305-L325
|
15,790
|
ionelmc/python-redis-lock
|
src/redis_lock/__init__.py
|
Lock._stop_lock_renewer
|
def _stop_lock_renewer(self):
"""
Stop the lock renewer.
This signals the renewal thread and waits for its exit.
"""
if self._lock_renewal_thread is None or not self._lock_renewal_thread.is_alive():
return
logger.debug("Signalling the lock refresher to stop")
self._lock_renewal_stop.set()
self._lock_renewal_thread.join()
self._lock_renewal_thread = None
logger.debug("Lock refresher has stopped")
|
python
|
def _stop_lock_renewer(self):
"""
Stop the lock renewer.
This signals the renewal thread and waits for its exit.
"""
if self._lock_renewal_thread is None or not self._lock_renewal_thread.is_alive():
return
logger.debug("Signalling the lock refresher to stop")
self._lock_renewal_stop.set()
self._lock_renewal_thread.join()
self._lock_renewal_thread = None
logger.debug("Lock refresher has stopped")
|
[
"def",
"_stop_lock_renewer",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lock_renewal_thread",
"is",
"None",
"or",
"not",
"self",
".",
"_lock_renewal_thread",
".",
"is_alive",
"(",
")",
":",
"return",
"logger",
".",
"debug",
"(",
"\"Signalling the lock refresher to stop\"",
")",
"self",
".",
"_lock_renewal_stop",
".",
"set",
"(",
")",
"self",
".",
"_lock_renewal_thread",
".",
"join",
"(",
")",
"self",
".",
"_lock_renewal_thread",
"=",
"None",
"logger",
".",
"debug",
"(",
"\"Lock refresher has stopped\"",
")"
] |
Stop the lock renewer.
This signals the renewal thread and waits for its exit.
|
[
"Stop",
"the",
"lock",
"renewer",
"."
] |
5481cd88b64d86d318e389c79b0575a73464b1f5
|
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L327-L339
|
15,791
|
ionelmc/python-redis-lock
|
src/redis_lock/__init__.py
|
Lock.release
|
def release(self):
"""Releases the lock, that was acquired with the same object.
.. note::
If you want to release a lock that you acquired in a different place you have two choices:
* Use ``Lock("name", id=id_from_other_place).release()``
* Use ``Lock("name").reset()``
"""
if self._lock_renewal_thread is not None:
self._stop_lock_renewer()
logger.debug("Releasing %r.", self._name)
error = _eval_script(self._client, UNLOCK, self._name, self._signal, args=(self._id,))
if error == 1:
raise NotAcquired("Lock %s is not acquired or it already expired." % self._name)
elif error:
raise RuntimeError("Unsupported error code %s from EXTEND script." % error)
else:
self._delete_signal()
|
python
|
def release(self):
"""Releases the lock, that was acquired with the same object.
.. note::
If you want to release a lock that you acquired in a different place you have two choices:
* Use ``Lock("name", id=id_from_other_place).release()``
* Use ``Lock("name").reset()``
"""
if self._lock_renewal_thread is not None:
self._stop_lock_renewer()
logger.debug("Releasing %r.", self._name)
error = _eval_script(self._client, UNLOCK, self._name, self._signal, args=(self._id,))
if error == 1:
raise NotAcquired("Lock %s is not acquired or it already expired." % self._name)
elif error:
raise RuntimeError("Unsupported error code %s from EXTEND script." % error)
else:
self._delete_signal()
|
[
"def",
"release",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lock_renewal_thread",
"is",
"not",
"None",
":",
"self",
".",
"_stop_lock_renewer",
"(",
")",
"logger",
".",
"debug",
"(",
"\"Releasing %r.\"",
",",
"self",
".",
"_name",
")",
"error",
"=",
"_eval_script",
"(",
"self",
".",
"_client",
",",
"UNLOCK",
",",
"self",
".",
"_name",
",",
"self",
".",
"_signal",
",",
"args",
"=",
"(",
"self",
".",
"_id",
",",
")",
")",
"if",
"error",
"==",
"1",
":",
"raise",
"NotAcquired",
"(",
"\"Lock %s is not acquired or it already expired.\"",
"%",
"self",
".",
"_name",
")",
"elif",
"error",
":",
"raise",
"RuntimeError",
"(",
"\"Unsupported error code %s from EXTEND script.\"",
"%",
"error",
")",
"else",
":",
"self",
".",
"_delete_signal",
"(",
")"
] |
Releases the lock, that was acquired with the same object.
.. note::
If you want to release a lock that you acquired in a different place you have two choices:
* Use ``Lock("name", id=id_from_other_place).release()``
* Use ``Lock("name").reset()``
|
[
"Releases",
"the",
"lock",
"that",
"was",
"acquired",
"with",
"the",
"same",
"object",
"."
] |
5481cd88b64d86d318e389c79b0575a73464b1f5
|
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L349-L368
|
15,792
|
mitodl/edx-api-client
|
edx_api/course_detail/__init__.py
|
CourseDetails.get_detail
|
def get_detail(self, course_id):
"""
Fetches course details.
Args:
course_id (str): An edx course id.
Returns:
CourseDetail
"""
# the request is done in behalf of the current logged in user
resp = self._requester.get(
urljoin(
self._base_url,
'/api/courses/v1/courses/{course_key}/'.format(course_key=course_id)
)
)
resp.raise_for_status()
return CourseDetail(resp.json())
|
python
|
def get_detail(self, course_id):
"""
Fetches course details.
Args:
course_id (str): An edx course id.
Returns:
CourseDetail
"""
# the request is done in behalf of the current logged in user
resp = self._requester.get(
urljoin(
self._base_url,
'/api/courses/v1/courses/{course_key}/'.format(course_key=course_id)
)
)
resp.raise_for_status()
return CourseDetail(resp.json())
|
[
"def",
"get_detail",
"(",
"self",
",",
"course_id",
")",
":",
"# the request is done in behalf of the current logged in user",
"resp",
"=",
"self",
".",
"_requester",
".",
"get",
"(",
"urljoin",
"(",
"self",
".",
"_base_url",
",",
"'/api/courses/v1/courses/{course_key}/'",
".",
"format",
"(",
"course_key",
"=",
"course_id",
")",
")",
")",
"resp",
".",
"raise_for_status",
"(",
")",
"return",
"CourseDetail",
"(",
"resp",
".",
"json",
"(",
")",
")"
] |
Fetches course details.
Args:
course_id (str): An edx course id.
Returns:
CourseDetail
|
[
"Fetches",
"course",
"details",
"."
] |
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
|
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/course_detail/__init__.py#L16-L36
|
15,793
|
mitodl/edx-api-client
|
edx_api/user_info/__init__.py
|
UserInfo.get_user_info
|
def get_user_info(self):
"""
Returns a UserInfo object for the logged in user.
Returns:
UserInfo: object representing the student current grades
"""
# the request is done in behalf of the current logged in user
resp = self.requester.get(
urljoin(
self.base_url,
'/api/mobile/v0.5/my_user_info'
)
)
resp.raise_for_status()
return Info(resp.json())
|
python
|
def get_user_info(self):
"""
Returns a UserInfo object for the logged in user.
Returns:
UserInfo: object representing the student current grades
"""
# the request is done in behalf of the current logged in user
resp = self.requester.get(
urljoin(
self.base_url,
'/api/mobile/v0.5/my_user_info'
)
)
resp.raise_for_status()
return Info(resp.json())
|
[
"def",
"get_user_info",
"(",
"self",
")",
":",
"# the request is done in behalf of the current logged in user",
"resp",
"=",
"self",
".",
"requester",
".",
"get",
"(",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"'/api/mobile/v0.5/my_user_info'",
")",
")",
"resp",
".",
"raise_for_status",
"(",
")",
"return",
"Info",
"(",
"resp",
".",
"json",
"(",
")",
")"
] |
Returns a UserInfo object for the logged in user.
Returns:
UserInfo: object representing the student current grades
|
[
"Returns",
"a",
"UserInfo",
"object",
"for",
"the",
"logged",
"in",
"user",
"."
] |
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
|
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/user_info/__init__.py#L21-L38
|
15,794
|
mitodl/edx-api-client
|
edx_api/course_structure/__init__.py
|
CourseStructure.course_blocks
|
def course_blocks(self, course_id, username):
"""
Fetches course blocks.
Args:
course_id (str): An edx course id.
username (str): username of the user to query for (can reveal hidden
modules)
Returns:
Structure
"""
resp = self.requester.get(
urljoin(self.base_url, '/api/courses/v1/blocks/'),
params={
"depth": "all",
"username": username,
"course_id": course_id,
"requested_fields": "children,display_name,id,type,visible_to_staff_only",
})
resp.raise_for_status()
return Structure(resp.json())
|
python
|
def course_blocks(self, course_id, username):
"""
Fetches course blocks.
Args:
course_id (str): An edx course id.
username (str): username of the user to query for (can reveal hidden
modules)
Returns:
Structure
"""
resp = self.requester.get(
urljoin(self.base_url, '/api/courses/v1/blocks/'),
params={
"depth": "all",
"username": username,
"course_id": course_id,
"requested_fields": "children,display_name,id,type,visible_to_staff_only",
})
resp.raise_for_status()
return Structure(resp.json())
|
[
"def",
"course_blocks",
"(",
"self",
",",
"course_id",
",",
"username",
")",
":",
"resp",
"=",
"self",
".",
"requester",
".",
"get",
"(",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"'/api/courses/v1/blocks/'",
")",
",",
"params",
"=",
"{",
"\"depth\"",
":",
"\"all\"",
",",
"\"username\"",
":",
"username",
",",
"\"course_id\"",
":",
"course_id",
",",
"\"requested_fields\"",
":",
"\"children,display_name,id,type,visible_to_staff_only\"",
",",
"}",
")",
"resp",
".",
"raise_for_status",
"(",
")",
"return",
"Structure",
"(",
"resp",
".",
"json",
"(",
")",
")"
] |
Fetches course blocks.
Args:
course_id (str): An edx course id.
username (str): username of the user to query for (can reveal hidden
modules)
Returns:
Structure
|
[
"Fetches",
"course",
"blocks",
"."
] |
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
|
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/course_structure/__init__.py#L15-L38
|
15,795
|
mitodl/edx-api-client
|
edx_api/grades/__init__.py
|
UserCurrentGrades.get_student_current_grade
|
def get_student_current_grade(self, username, course_id):
"""
Returns an CurrentGrade object for the user in a course
Args:
username (str): an edx user's username
course_id (str): an edX course id.
Returns:
CurrentGrade: object representing the student current grade for a course
"""
# the request is done in behalf of the current logged in user
resp = self.requester.get(
urljoin(
self.base_url,
'/api/grades/v1/courses/{course_key}/?username={username}'.format(
username=username,
course_key=course_id
)
)
)
resp.raise_for_status()
return CurrentGrade(resp.json()[0])
|
python
|
def get_student_current_grade(self, username, course_id):
"""
Returns an CurrentGrade object for the user in a course
Args:
username (str): an edx user's username
course_id (str): an edX course id.
Returns:
CurrentGrade: object representing the student current grade for a course
"""
# the request is done in behalf of the current logged in user
resp = self.requester.get(
urljoin(
self.base_url,
'/api/grades/v1/courses/{course_key}/?username={username}'.format(
username=username,
course_key=course_id
)
)
)
resp.raise_for_status()
return CurrentGrade(resp.json()[0])
|
[
"def",
"get_student_current_grade",
"(",
"self",
",",
"username",
",",
"course_id",
")",
":",
"# the request is done in behalf of the current logged in user",
"resp",
"=",
"self",
".",
"requester",
".",
"get",
"(",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"'/api/grades/v1/courses/{course_key}/?username={username}'",
".",
"format",
"(",
"username",
"=",
"username",
",",
"course_key",
"=",
"course_id",
")",
")",
")",
"resp",
".",
"raise_for_status",
"(",
")",
"return",
"CurrentGrade",
"(",
"resp",
".",
"json",
"(",
")",
"[",
"0",
"]",
")"
] |
Returns an CurrentGrade object for the user in a course
Args:
username (str): an edx user's username
course_id (str): an edX course id.
Returns:
CurrentGrade: object representing the student current grade for a course
|
[
"Returns",
"an",
"CurrentGrade",
"object",
"for",
"the",
"user",
"in",
"a",
"course"
] |
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
|
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/grades/__init__.py#L25-L49
|
15,796
|
mitodl/edx-api-client
|
edx_api/grades/__init__.py
|
UserCurrentGrades.get_student_current_grades
|
def get_student_current_grades(self, username, course_ids=None):
"""
Returns a CurrentGradesByUser object with the user current grades.
Args:
username (str): an edx user's username
course_ids (list): a list of edX course ids.
Returns:
CurrentGradesByUser: object representing the student current grades
"""
# if no course ids are provided, let's get the user enrollments
if course_ids is None:
enrollments_client = CourseEnrollments(self.requester, self.base_url)
enrollments = enrollments_client.get_student_enrollments()
course_ids = list(enrollments.get_enrolled_course_ids())
all_current_grades = []
for course_id in course_ids:
try:
all_current_grades.append(self.get_student_current_grade(username, course_id))
except HTTPError as error:
if error.response.status_code >= 500:
raise
return CurrentGradesByUser(all_current_grades)
|
python
|
def get_student_current_grades(self, username, course_ids=None):
"""
Returns a CurrentGradesByUser object with the user current grades.
Args:
username (str): an edx user's username
course_ids (list): a list of edX course ids.
Returns:
CurrentGradesByUser: object representing the student current grades
"""
# if no course ids are provided, let's get the user enrollments
if course_ids is None:
enrollments_client = CourseEnrollments(self.requester, self.base_url)
enrollments = enrollments_client.get_student_enrollments()
course_ids = list(enrollments.get_enrolled_course_ids())
all_current_grades = []
for course_id in course_ids:
try:
all_current_grades.append(self.get_student_current_grade(username, course_id))
except HTTPError as error:
if error.response.status_code >= 500:
raise
return CurrentGradesByUser(all_current_grades)
|
[
"def",
"get_student_current_grades",
"(",
"self",
",",
"username",
",",
"course_ids",
"=",
"None",
")",
":",
"# if no course ids are provided, let's get the user enrollments",
"if",
"course_ids",
"is",
"None",
":",
"enrollments_client",
"=",
"CourseEnrollments",
"(",
"self",
".",
"requester",
",",
"self",
".",
"base_url",
")",
"enrollments",
"=",
"enrollments_client",
".",
"get_student_enrollments",
"(",
")",
"course_ids",
"=",
"list",
"(",
"enrollments",
".",
"get_enrolled_course_ids",
"(",
")",
")",
"all_current_grades",
"=",
"[",
"]",
"for",
"course_id",
"in",
"course_ids",
":",
"try",
":",
"all_current_grades",
".",
"append",
"(",
"self",
".",
"get_student_current_grade",
"(",
"username",
",",
"course_id",
")",
")",
"except",
"HTTPError",
"as",
"error",
":",
"if",
"error",
".",
"response",
".",
"status_code",
">=",
"500",
":",
"raise",
"return",
"CurrentGradesByUser",
"(",
"all_current_grades",
")"
] |
Returns a CurrentGradesByUser object with the user current grades.
Args:
username (str): an edx user's username
course_ids (list): a list of edX course ids.
Returns:
CurrentGradesByUser: object representing the student current grades
|
[
"Returns",
"a",
"CurrentGradesByUser",
"object",
"with",
"the",
"user",
"current",
"grades",
"."
] |
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
|
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/grades/__init__.py#L51-L76
|
15,797
|
mitodl/edx-api-client
|
edx_api/grades/__init__.py
|
UserCurrentGrades.get_course_current_grades
|
def get_course_current_grades(self, course_id):
"""
Returns a CurrentGradesByCourse object for all users in the specified course.
Args:
course_id (str): an edX course ids.
Returns:
CurrentGradesByCourse: object representing the student current grades
Authorization:
The authenticated user must have staff permissions to see grades for all users
in a course.
"""
resp = self.requester.get(
urljoin(
self.base_url,
'/api/grades/v1/courses/{course_key}/'.format(course_key=course_id)
)
)
resp.raise_for_status()
resp_json = resp.json()
if 'results' in resp_json:
grade_entries = [CurrentGrade(entry) for entry in resp_json["results"]]
while resp_json['next'] is not None:
resp = self.requester.get(resp_json['next'])
resp.raise_for_status()
resp_json = resp.json()
grade_entries.extend((CurrentGrade(entry) for entry in resp_json["results"]))
else:
grade_entries = [CurrentGrade(entry) for entry in resp_json]
return CurrentGradesByCourse(grade_entries)
|
python
|
def get_course_current_grades(self, course_id):
"""
Returns a CurrentGradesByCourse object for all users in the specified course.
Args:
course_id (str): an edX course ids.
Returns:
CurrentGradesByCourse: object representing the student current grades
Authorization:
The authenticated user must have staff permissions to see grades for all users
in a course.
"""
resp = self.requester.get(
urljoin(
self.base_url,
'/api/grades/v1/courses/{course_key}/'.format(course_key=course_id)
)
)
resp.raise_for_status()
resp_json = resp.json()
if 'results' in resp_json:
grade_entries = [CurrentGrade(entry) for entry in resp_json["results"]]
while resp_json['next'] is not None:
resp = self.requester.get(resp_json['next'])
resp.raise_for_status()
resp_json = resp.json()
grade_entries.extend((CurrentGrade(entry) for entry in resp_json["results"]))
else:
grade_entries = [CurrentGrade(entry) for entry in resp_json]
return CurrentGradesByCourse(grade_entries)
|
[
"def",
"get_course_current_grades",
"(",
"self",
",",
"course_id",
")",
":",
"resp",
"=",
"self",
".",
"requester",
".",
"get",
"(",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"'/api/grades/v1/courses/{course_key}/'",
".",
"format",
"(",
"course_key",
"=",
"course_id",
")",
")",
")",
"resp",
".",
"raise_for_status",
"(",
")",
"resp_json",
"=",
"resp",
".",
"json",
"(",
")",
"if",
"'results'",
"in",
"resp_json",
":",
"grade_entries",
"=",
"[",
"CurrentGrade",
"(",
"entry",
")",
"for",
"entry",
"in",
"resp_json",
"[",
"\"results\"",
"]",
"]",
"while",
"resp_json",
"[",
"'next'",
"]",
"is",
"not",
"None",
":",
"resp",
"=",
"self",
".",
"requester",
".",
"get",
"(",
"resp_json",
"[",
"'next'",
"]",
")",
"resp",
".",
"raise_for_status",
"(",
")",
"resp_json",
"=",
"resp",
".",
"json",
"(",
")",
"grade_entries",
".",
"extend",
"(",
"(",
"CurrentGrade",
"(",
"entry",
")",
"for",
"entry",
"in",
"resp_json",
"[",
"\"results\"",
"]",
")",
")",
"else",
":",
"grade_entries",
"=",
"[",
"CurrentGrade",
"(",
"entry",
")",
"for",
"entry",
"in",
"resp_json",
"]",
"return",
"CurrentGradesByCourse",
"(",
"grade_entries",
")"
] |
Returns a CurrentGradesByCourse object for all users in the specified course.
Args:
course_id (str): an edX course ids.
Returns:
CurrentGradesByCourse: object representing the student current grades
Authorization:
The authenticated user must have staff permissions to see grades for all users
in a course.
|
[
"Returns",
"a",
"CurrentGradesByCourse",
"object",
"for",
"all",
"users",
"in",
"the",
"specified",
"course",
"."
] |
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
|
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/grades/__init__.py#L78-L110
|
15,798
|
mitodl/edx-api-client
|
edx_api/client.py
|
EdxApi.get_requester
|
def get_requester(self):
"""
Returns an object to make authenticated requests. See python `requests` for the API.
"""
# TODO(abrahms): Perhaps pull this out into a factory function for
# generating an EdxApi instance with the proper requester & credentials.
session = requests.session()
session.headers.update({
'Authorization': 'Bearer {}'.format(self.credentials['access_token'])
})
old_request = session.request
def patched_request(*args, **kwargs):
"""
adds timeout param to session.request
"""
return old_request(*args, timeout=self.timeout, **kwargs)
session.request = patched_request
return session
|
python
|
def get_requester(self):
"""
Returns an object to make authenticated requests. See python `requests` for the API.
"""
# TODO(abrahms): Perhaps pull this out into a factory function for
# generating an EdxApi instance with the proper requester & credentials.
session = requests.session()
session.headers.update({
'Authorization': 'Bearer {}'.format(self.credentials['access_token'])
})
old_request = session.request
def patched_request(*args, **kwargs):
"""
adds timeout param to session.request
"""
return old_request(*args, timeout=self.timeout, **kwargs)
session.request = patched_request
return session
|
[
"def",
"get_requester",
"(",
"self",
")",
":",
"# TODO(abrahms): Perhaps pull this out into a factory function for",
"# generating an EdxApi instance with the proper requester & credentials.",
"session",
"=",
"requests",
".",
"session",
"(",
")",
"session",
".",
"headers",
".",
"update",
"(",
"{",
"'Authorization'",
":",
"'Bearer {}'",
".",
"format",
"(",
"self",
".",
"credentials",
"[",
"'access_token'",
"]",
")",
"}",
")",
"old_request",
"=",
"session",
".",
"request",
"def",
"patched_request",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"\n adds timeout param to session.request\n \"\"\"",
"return",
"old_request",
"(",
"*",
"args",
",",
"timeout",
"=",
"self",
".",
"timeout",
",",
"*",
"*",
"kwargs",
")",
"session",
".",
"request",
"=",
"patched_request",
"return",
"session"
] |
Returns an object to make authenticated requests. See python `requests` for the API.
|
[
"Returns",
"an",
"object",
"to",
"make",
"authenticated",
"requests",
".",
"See",
"python",
"requests",
"for",
"the",
"API",
"."
] |
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
|
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/client.py#L30-L50
|
15,799
|
mitodl/edx-api-client
|
edx_api/ccx.py
|
CCX.create
|
def create(self, master_course_id, coach_email, max_students_allowed, title, modules=None):
"""
Creates a CCX
Args:
master_course_id (str): edx course id of the master course
coach_email (str): email of the user to make a coach. This user must exist on edx.
max_students_allowed (int): Maximum number of students to allow in this ccx.
title (str): Title of the CCX to be created
modules (optional list): A list of locator_ids (str) for the modules to enable.
Returns:
ccx_id (str): The ID of the ccx.
"""
payload = {
'master_course_id': master_course_id,
'coach_email': coach_email,
'max_students_allowed': max_students_allowed,
'display_name': title,
}
if modules is not None:
payload['course_modules'] = modules
resp = self.requester.post(
parse.urljoin(self.base_url, '/api/ccx/v0/ccx/'),
json=payload
)
try:
resp.raise_for_status()
except:
log.error(resp.json())
raise
return resp.json()['ccx_course_id']
|
python
|
def create(self, master_course_id, coach_email, max_students_allowed, title, modules=None):
"""
Creates a CCX
Args:
master_course_id (str): edx course id of the master course
coach_email (str): email of the user to make a coach. This user must exist on edx.
max_students_allowed (int): Maximum number of students to allow in this ccx.
title (str): Title of the CCX to be created
modules (optional list): A list of locator_ids (str) for the modules to enable.
Returns:
ccx_id (str): The ID of the ccx.
"""
payload = {
'master_course_id': master_course_id,
'coach_email': coach_email,
'max_students_allowed': max_students_allowed,
'display_name': title,
}
if modules is not None:
payload['course_modules'] = modules
resp = self.requester.post(
parse.urljoin(self.base_url, '/api/ccx/v0/ccx/'),
json=payload
)
try:
resp.raise_for_status()
except:
log.error(resp.json())
raise
return resp.json()['ccx_course_id']
|
[
"def",
"create",
"(",
"self",
",",
"master_course_id",
",",
"coach_email",
",",
"max_students_allowed",
",",
"title",
",",
"modules",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'master_course_id'",
":",
"master_course_id",
",",
"'coach_email'",
":",
"coach_email",
",",
"'max_students_allowed'",
":",
"max_students_allowed",
",",
"'display_name'",
":",
"title",
",",
"}",
"if",
"modules",
"is",
"not",
"None",
":",
"payload",
"[",
"'course_modules'",
"]",
"=",
"modules",
"resp",
"=",
"self",
".",
"requester",
".",
"post",
"(",
"parse",
".",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"'/api/ccx/v0/ccx/'",
")",
",",
"json",
"=",
"payload",
")",
"try",
":",
"resp",
".",
"raise_for_status",
"(",
")",
"except",
":",
"log",
".",
"error",
"(",
"resp",
".",
"json",
"(",
")",
")",
"raise",
"return",
"resp",
".",
"json",
"(",
")",
"[",
"'ccx_course_id'",
"]"
] |
Creates a CCX
Args:
master_course_id (str): edx course id of the master course
coach_email (str): email of the user to make a coach. This user must exist on edx.
max_students_allowed (int): Maximum number of students to allow in this ccx.
title (str): Title of the CCX to be created
modules (optional list): A list of locator_ids (str) for the modules to enable.
Returns:
ccx_id (str): The ID of the ccx.
|
[
"Creates",
"a",
"CCX"
] |
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
|
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/ccx.py#L20-L55
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.