Skip to content

Instantly share code, notes, and snippets.

View hartsock's full-sized avatar

Shawn Hartsock hartsock

View GitHub Profile
@hartsock
hartsock / debug_http.py
Created July 7, 2014 19:32
A snippet of code that shows how to turn on debugging for the Python HTTP client library
import requests
import logging
# These two lines enable debugging at httplib level (requests->urllib3->http.client)
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# The only thing missing will be the response.body which is not logged.
try:
import http.client as http_client
except ImportError:
# Python 2
@hartsock
hartsock / vmomi-support-py3-load
Last active August 29, 2015 14:03
dirtied up loader output under python3
/Users/hartsocks/.venv/pyvmomi-tools-py3/bin/python3 /Users/hartsocks/PycharmProjects/pyvmomi/sample/getallvms.py -s 192.168.2.11 -u root -p vmware
add to dependency map ['ManagedObject']
ManagedObject
add to dependency map ['DataObject']
DataObject
add to dependency map ['vmodl', 'DynamicArray']
vmodl
DynamicArray
len: 1
curName: vmodl.DynamicArray
@hartsock
hartsock / vmomi-support-py2-load
Created July 3, 2014 14:12
dirtied up loader output under python2
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/hartsocks/PycharmProjects/pyvmomi/sample/getallvms.py -s 192.168.2.11 -u root -p vmware
('add to dependency map', ['ManagedObject'])
ManagedObject
('add to dependency map', ['DataObject'])
DataObject
('add to dependency map', ['vmodl', 'DynamicArray'])
vmodl
('\t', 'DynamicArray')
('\t curName: ', 'vmodl.DynamicArray')
('add to dependency map', ['vmodl', 'DynamicData'])
@hartsock
hartsock / outputoftest.py
Created July 1, 2014 21:51
Output of Test Connection .py The dynamic class loader breaks on python 3 after trivial python 2 to 3 porting is completed. Can it be fixed?
Traceback (most recent call last):
File "/Users/hartsocks/PycharmProjects/pyvmomi/pyVmomi/VmomiSupport.py", line 265, in __getattr__
typeObj = GetWsdlType(XMLNS_VMODL_BASE, attr)
File "/Users/hartsocks/PycharmProjects/pyvmomi/pyVmomi/VmomiSupport.py", line 1018, in GetWsdlType
typ = _LoadVmodlType(_wsdlDefMap[(ns, name)][0])
KeyError: ('urn:vim25', 'fault')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
@hartsock
hartsock / getallvms.py
Created July 1, 2014 18:09
Trace from getallvms.py when run on Python 3.
pyvmomi/sample/getallvms.py -s test_host -u test_user -p test_password
Traceback (most recent call last):
File "/Users/hartsocks/PycharmProjects/pyvmomi/sample/getallvms.py", line 22, in <module>
from pyVim.connect import SmartConnect, Disconnect
File "/Users/hartsocks/PycharmProjects/pyvmomi/pyVim/connect.py", line 57, in <module>
from pyVmomi import vim, vmodl, SoapStubAdapter, SessionOrientedStub
ImportError: cannot import name 'vim'
@hartsock
hartsock / spline.cpp
Created June 27, 2014 20:53
One of my old homework assignments that keeps cropping up on the web.
//**************************************
// Name: OpenGL Spine drawing app
// Description:It's a Spline Drawing Application that uses the OpenGL Libraries. I used the GLUT event handler interface to control Mouse functions.You will Need:
OpenGL
Glut
and a C++ compiler
Found at: http://modzer0.cs.uaf.edu/~hartsock/C_Cpp/OpenGL/Splines.html
// By: Found on the World Wide Web
//
//
@hartsock
hartsock / Gravity.cpp
Created June 27, 2014 16:18
Found wandering the web, one of my original OpenGL projects. A homework assignment from 1998.
/************************************************************************\
|
| Shawn R. Hartsock Gravity.cpp
| CS 381 Uses STL
| Prof: Hartman
| due: 12/16/1998
|
Simulates Gravity. See PreDefined Menu... My favorite is to set
collisions to absorbative and choose explode from the predef. menu
| Keys : z,x,i,j,k,l,
@hartsock
hartsock / Gravity(sgi).cpp
Created June 27, 2014 16:17
Found wandering the web, one of my original C++ files posted on a long dead website.
/************************************************************************\
|
| Shawn R. Hartsock Gravity.cpp
| CS 381 Uses STL (SGI version)
| Prof: Hartman Note: Win32 version is different.
| due: 12/16/1998
|
| *executable* at: ../hartsock/homework/Hw09/Gravity
|
@hartsock
hartsock / link.py
Created June 26, 2014 17:42
A problematic snippet of Python 2.6 code I need to port to Python 3
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
# usage: ruby import.rb my-blog.xml
# my-blog.xml is a file from Settings -> Basic -> Export in blogger.
data = File.read ARGV[0]