rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print "Download of vmlinuz and initrd.img finished"
def setup_url(self): """ Download the vmlinuz and initrd.img from URL. """ print "Downloading the vmlinuz and initrd.img" os.chdir(self.image_path)
kernel_fetch_cmd = ("cp %s/isolinux/%s %s" % (self.nfs_mount, self.kernel, self.image_path))
kernel_fetch_cmd = ("cp %s/%s/%s %s" % (self.nfs_mount, self.boot_path, self.kernel, self.image_path))
def setup_nfs(self): """ Copy the vmlinuz and initrd.img from nfs. """ print "Copying the vmlinuz and initrd.img from nfs"
initrd_fetch_cmd = ("cp %s/isolinux/%s %s" % (self.nfs_mount, self.initrd, self.image_path))
initrd_fetch_cmd = ("cp %s/%s/%s %s" % (self.nfs_mount, self.boot_path, self.initrd, self.image_path))
def setup_nfs(self): """ Copy the vmlinuz and initrd.img from nfs. """ print "Copying the vmlinuz and initrd.img from nfs"
if self.tftp: self.setup_pxe_boot()
if self.kernel and self.initrd: self.setup_cdrom()
def setup(self): """ Configure the environment for unattended install.
log_filename = ("scp-%s-%s.log" % (self.name, kvm_utils.generate_random_string(4)))
def copy_files_to(self, local_path, remote_path, nic_index=0, timeout=600): """ Transfer files to the guest.
log_filename = ("scp-%s-%s.log" % (self.name, kvm_utils.generate_random_string(4)))
def copy_files_from(self, remote_path, local_path, nic_index=0, timeout=600): """ Transfer files from the guest.
def _remote_login(session, password, prompt, timeout=10):
def _remote_login(session, username, password, prompt, timeout=10):
def _remote_login(session, password, prompt, timeout=10): """ Log into a remote host (guest) using SSH or Telnet. Wait for questions and provide answers. If timeout expires while waiting for output from the child (e.g. a password prompt or a shell prompt) -- fail. @brief: Log into a remote host (guest) using SSH or ...
logging.debug("Got unexpected login prompt") return False
if login_prompt_count == 0: logging.debug("Got username prompt; sending '%s'" % username) session.sendline(username) login_prompt_count += 1 continue else: logging.debug("Got username prompt again") return False
def _remote_login(session, password, prompt, timeout=10): """ Log into a remote host (guest) using SSH or Telnet. Wait for questions and provide answers. If timeout expires while waiting for output from the child (e.g. a password prompt or a shell prompt) -- fail. @brief: Log into a remote host (guest) using SSH or ...
if _remote_login(session, password, prompt, timeout):
if _remote_login(session, username, password, prompt, timeout):
def remote_login(client, host, port, username, password, prompt, linesep="\n", timeout=10): """ Log into a remote host (guest) using SSH/Telnet/Netcat. @param client: The client to use ('ssh', 'telnet' or 'nc') @param host: Hostname or IP address @param port: Port to connect to @param username: Username (if required) ...
found_mac_addresses = re.findall("macaddr=(.*)", o)
found_mac_addresses = re.findall("macaddr=(\S+)", o)
def chk_fmt_model(device, fmt_model, info_cmd, str): f_fail = 0 devices = kvm_utils.get_sub_dict_names(params, device) for chk_device in devices: expected = kvm_utils.get_sub_dict(params, chk_device).get(fmt_model) if not expected: expected = "rtl8139" try: o = vm.monitor.info(info_cmd) except kvm_monitor.MonitorError,...
s = re.findall(time_filter_re, s)[0]
try: s = re.findall(time_filter_re, s)[0] except IndexError: logging.debug("The time string from guest is:\n%s" % s) raise error.TestError("The time string from guest is unexpected.") except Exception as e: logging.debug("(time_filter_re, time_string): (%s, %s)" % (time_filter_re, s)) raise e
def get_time(session, time_command, time_filter_re, time_format): """ Return the host time and guest time. If the guest time cannot be fetched a TestError exception is raised. Note that the shell session should be ready to receive commands (i.e. should "display" a command prompt and should be done with all previous c...
except CmdError, e:
except error.CmdError, e:
def run_once(self, test='antlr', config='./dacapo.cfg', jvm='default'): cfg = config_loader(cfg=config, tmpdir=self.tmpdir, raise_errors=True) self.test = test cachedir = os.path.join(self.bindir, 'cache') if not os.path.isdir(cachedir): os.makedirs(cachedir)
conn.chanserv.set_channel_flag(channel, 'TOPICLOCK', TOPICLOCK) conn.chanserv.set_channel_flag(channel, 'SECURE', SECURE) conn.chanserv.set_channel_flag(channel, 'FANTASY', FANTASY) conn.chanserv.set_channel_flag(channel, 'RESTRICTED', RESTRICTED) conn.chanserv.set_channel_flag(channel, 'PRIVATE', PRIVATE) conn.chanser...
params = { 'TOPICLOCK': TOPICLOCK, 'SECURE': SECURE, 'FANTASY': FANTASY, 'RESTRICTED': RESTRICTED, 'PRIVATE': PRIVATE, 'KEEPTOPIC': KEEPTOPIC, 'LIMITFLAGS': LIMITFLAGS, 'VERBOSE': VERBOSE, } for key in params.keys(): try: conn.chanserv.set_channel_flag(channel, key, params[key]) except: pass webinfo.response.status =...
def settings_commit(self, channel, TOPICLOCK='OFF', SECURE='OFF', FANTASY='OFF', RESTRICTED='OFF', VERBOSE_OPS='OFF', PRIVATE='OFF', KEEPTOPIC='OFF', GUARD='OFF', LIMITFLAGS='OFF', HOLD='OFF', VERBOSE='OFF'): try: conn = get_xmlrpc_connection() except: webinfo.response.status = "302 Found" webinfo.response.headers['loc...
ak = i.split(' - ', 4)
ak = i.split(' - ', 3)
def akill_list(self): akills = self.parent.atheme.command(self.parent.authcookie, self.parent.username, self.parent.ipaddr, 'OperServ', 'AKILL', 'LIST', 'FULL').split('\n')[1:-1] akillset = {}
'setter': ak[2].split(' ')[1], 'expiry': ak[3], 'reason': ak[4]}
'setter': ak[1].split(' ')[1], 'expiry': ak[2], 'reason': ak[3][1:-1]}
def akill_list(self): akills = self.parent.atheme.command(self.parent.authcookie, self.parent.username, self.parent.ipaddr, 'OperServ', 'AKILL', 'LIST', 'FULL').split('\n')[1:-1] akillset = {}
httpserver.serve(make_app({'debug': True, 'expiration': 60}), host='0.0.0.0', port='8080')
if len(sys.argv) == 2: if sys.argv[1] == '--debug': httpserver.serve(make_app({'debug': True, 'expiration': 60}), host='0.0.0.0', port='8080') else: httpserver.serve(make_app({'debug': False, 'expiration': 60}), host='0.0.0.0', port='8080')
def make_app(global_conf=None): from middleware.classpublisher import ClassPublisher from athemeweb.webroot import WebRoot real_app = ClassPublisher(WebRoot()) from paste.exceptions.errormiddleware import ErrorMiddleware error_app = ErrorMiddleware(real_app, global_conf=global_conf) from paste.session import SessionM...
ak = i.split(' ', 8) aki = {'num': int(ak[0].strip(':')), 'mask': ak[1], 'setter': ak[4], 'expiry': ak[6], 'reason': ak[8]}
ak = i.split(' - ', 4) aki = {'num': int(ak[0].split(' ')[0].strip(':')), 'mask': ak[0].split(' ')[1], 'setter': ak[2].split(' ')[1], 'expiry': ak[3], 'reason': ak[4]}
def akill_list(self): akills = self.parent.atheme.command(self.parent.authcookie, self.parent.username, self.parent.ipaddr, 'OperServ', 'AKILL', 'LIST', 'FULL').split('\n')[1:-1] akillset = {}
if page['privs'] is None or conn.has_privilege(page['privs']):
if page['privs'] is None or (conn is not None and conn.has_privilege(page['privs'])):
def build_page_set(conn): pageset = { 'account': { 'title': "My Account", 'privs': None }, 'channel/list': { 'title': "My Channels", 'privs': None }, 'memo/list': { 'title': "Memo Inbox", 'privs': None }, 'memo/write': { 'title': "New Memo", 'privs': None }, 'akill/list': { 'title': "AKILLs", 'privs': 'operserv:akill',...
if len(sys.argv):
if len(sys.argv) > 1:
def make_app(global_conf=None): from middleware.classpublisher import ClassPublisher from athemeweb.webroot import WebRoot real_app = ClassPublisher(WebRoot()) from paste.exceptions.errormiddleware import ErrorMiddleware error_app = ErrorMiddleware(real_app, global_conf=global_conf) from paste.session import SessionM...
"""Compares two strings and return their similarity.
"""Compares two strings and returns their similarity.
def compare(s1, s2, **kwargs): """Compares two strings and return their similarity.
def search(self, query, usekey=False, threshold=None): """Search the index for items that have similarity to the query.
def searchitem(self, item, threshold=None): """Search the index for items whose key exceeds the threshold similarity to the key of the given item. :return: list of pairs of (item,similarity) by decreasing similarity. >>> from ngram import NGram >>> n = NGram([(0,"ABCD"),(1,"ABCE"),(2,"FG")], key=lambda x:x[1]) >>> n....
def items_sharing_ngrams(self, query): """Retrieve the subset of items that share n-grams the query string.
the query. :param usekey: Use the `key` specified in the constructor to transform the query into a string. :param threshold: override the threshold specified in the constructor.
the query string.
def search(self, query, usekey=False, threshold=None): """Search the index for items that have similarity to the query.
>>> n = NGram([(0,"Josef"),(1,"Joseph"),(2,"Jo")], key=lambda x:x[1]) >>> n.search("osef") [((0, 'Josef'), 0.44444444444444442), ((1, 'Joseph'), 0.076923076923076927)] >>> n.search((3,"osef"), usekey=True) [((0, 'Josef'), 0.44444444444444442), ((1, 'Joseph'), 0.076923076923076927)] >>> n.search("Jo", threshold=0.25) [(...
>>> n = NGram([(0,"ABCD"),(1,"ABCE"),(2,"FG")], key=lambda x:x[1]) >>> n.search("ABC") [((0, 'ABCD'), 0.375), ((1, 'ABCE'), 0.375)] >>> n.search("D") [((0, 'ABCD'), 0.125)] >>> n.search("FG") [((2, 'FG'), 1.0)]
def search(self, query, usekey=False, threshold=None): """Search the index for items that have similarity to the query.
querystring = self.key(query) if usekey else query
def search(self, query, usekey=False, threshold=None): """Search the index for items that have similarity to the query.
for match, samegrams in self.items_sharing_ngrams(querystring).iteritems(): allgrams = (len(self.pad(querystring))
for match, samegrams in self.items_sharing_ngrams(query).iteritems(): allgrams = (len(self.pad(query))
def search(self, query, usekey=False, threshold=None): """Search the index for items that have similarity to the query.
def find(self, query, usekey=False, threshold=None):
def finditem(self, item, threshold=None): """Return most similar item to the provided one, or None if nothing exceeds the threshold. >>> from ngram import NGram >>> n = NGram([(0,"Joseph"),(1,"John"),(2,"Kim")], key=lambda x:x[1].lower()) >>> n.finditem((3,'Kam')) (2, 'Kim') >>> n.finditem((4,"Josef")) (0, 'Joseph') "...
def search(self, query, usekey=False, threshold=None): """Search the index for items that have similarity to the query.
results = self.search(query, usekey, threshold)
results = self.search(query, threshold)
def find(self, query, usekey=False, threshold=None): """Simply return the best match to the query, None on no match.
>>> NGram.compare('foo', 'foobar') 0.29999999999999999
>>> NGram.compare('foo', 'foob') 0.375
def compare(s1, s2, **kwargs): """Compares two strings and returns their similarity.
"""Return a new copy of the index.
"""Return a shallow copy of the NGram object. That is, instantiate a new NGram from references to items stored in this one. >>> from copy import deepcopy
def copy(self): """Return a new copy of the index. >>> n = NGram(['eggs', 'spam']) >>> m = n.copy() >>> m.add('ham') >>> n NGram(['eggs', 'spam']) >>> m NGram(['eggs', 'ham', 'spam']) """ builder, args = self.__reduce__() return builder(*args)
builder, args = self.__reduce__() return builder(*args)
return NGram(self, self.threshold, self.warp, self.key, self.N, self._pad_len, self._pad_char)
def copy(self): """Return a new copy of the index. >>> n = NGram(['eggs', 'spam']) >>> m = n.copy() >>> m.add('ham') >>> n NGram(['eggs', 'spam']) >>> m NGram(['eggs', 'ham', 'spam']) """ builder, args = self.__reduce__() return builder(*args)
return NGram, (list(self), self.threshold, self.warp, self.key,
return NGram, (list(self), self.threshold, self.warp, self._key,
def __reduce__(self): """Return state information for pickling, no references to this instance.""" return NGram, (list(self), self.threshold, self.warp, self.key, self.N, self._pad_len, self._pad_char)
return NGram(self, self.threshold, self.warp, self.key,
return NGram(self, self.threshold, self.warp, self._key,
def copy(self): """Return a shallow copy of the NGram object. That is, instantiate a new NGram from references to items stored in this one. >>> from copy import deepcopy >>> n = NGram(['eggs', 'spam']) >>> m = n.copy() >>> m.add('ham') >>> n NGram(['eggs', 'spam']) >>> m NGram(['eggs', 'ham', 'spam']) """ return NGra...
return reduce(Q.__and__, filters)
return reduce(getattr(self.Meta, 'default_operator', Q.__and__), filters)
def construct_search(field_name, first): if field_name.startswith('^'): if first: return "%s__istartswith" % field_name[1:] else: return "%s__icontains" % field_name[1:] elif field_name.startswith('='): return "%s__iexact" % field_name[1:] elif field_name.startswith('@'): if settings.DATABASE_ENGINE == 'mysql': return ...
cleaned_data = self.cleaned_data
cleaned_data = self.cleaned_data.copy()
def construct_filter_args(self, cleaned_data=None): args = [] if not cleaned_data: cleaned_data = self.cleaned_data # construct text search if cleaned_data['q']: args.append(self.get_text_search_query(cleaned_data.pop('q'))) # if its an instance of Q, append to filter args # otherwise assume an exact match lookup fo...
z.add_registration_code('def("readRaw", &::readRaw, ( arg("inst"), arg("fmt"), arg("len") ), "Reads raw data. Argument \'vec\' is returned as a Mat.")')
z.add_registration_code('def("readRaw", &::readRaw, ( bp::arg("inst"), bp::arg("fmt"), bp::arg("len") ), "Reads raw data. Argument \'vec\' is returned as a Mat.")')
def _MatND__repr__(self): return "MatND(shape=" + repr(self.ndarray.shape) + ", nchannels=" + repr(self.channels()) \ + ", depth=" + repr(self.depth()) + "):\\n" + repr(self.ndarray)
bp::object result = sdcpp::new_ndarray(1, &len, NPY_FLOAT, 0,
bp::object result = sdcpp::new_ndarray(1, &len, NPY_FLOAT,
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
print "bundled_files=", bundled_files
def find_libraries(library_dirs, libraries): files = [] for lib in libraries: for dir in library_dirs: if OP.exists(OP.join(dir, lib)): D.copy_file(OP.join(dir, lib), 'pyopencv') files.append(lib) break else: raise IOError("Library %s not found." % lib) return files
mb.decls(lambda x: 'CvFileStorage' in x.decl_string).exclude() mb.operators(lambda x: '*' in x.name or 'char' in x.decl_string).exclude()
z.decls(lambda x: 'CvFileStorage' in x.decl_string).exclude() z.operators(lambda x: '*' in x.name or 'char' in x.decl_string).exclude()
def _MatND__repr__(self): return "MatND(shape=" + repr(self.ndarray.shape) + ", nchannels=" + repr(self.channels()) \ + ", depth=" + repr(self.depth()) + "):\\n" + repr(self.ndarray)
static cv::Mat readRaw(cv::FileNode const &inst, std::string const &fmt)
static cv::Mat readRaw(cv::FileNode const &inst, std::string const &fmt, int len)
def _MatND__repr__(self): return "MatND(shape=" + repr(self.ndarray.shape) + ", nchannels=" + repr(self.channels()) \ + ", depth=" + repr(self.depth()) + "):\\n" + repr(self.ndarray)
int size = inst.rawDataSize(fmt); data.resize(size); inst.readRaw(fmt, &data[0], size);
data.resize(len); inst.readRaw(fmt, &data[0], len);
def _MatND__repr__(self): return "MatND(shape=" + repr(self.ndarray.shape) + ", nchannels=" + repr(self.channels()) \ + ", depth=" + repr(self.depth()) + "):\\n" + repr(self.ndarray)
z.add_registration_code('def("readRaw", &::readRaw, "Reads raw data. Argument \'len\' is determined using member \\nfunction \'rawDataSize()\'. Argument \'vec\' is returned as a Mat.")')
z.add_registration_code('def("readRaw", &::readRaw, ( arg("inst"), arg("fmt"), arg("len") ), "Reads raw data. Argument \'vec\' is returned as a Mat.")')
def _MatND__repr__(self): return "MatND(shape=" + repr(self.ndarray.shape) + ", nchannels=" + repr(self.channels()) \ + ", depth=" + repr(self.depth()) + "):\\n" + repr(self.ndarray)
testing.make-test run-pyd : pyopencvext _get_ext.py : : test_ext ;
testing.make-test run-pyd : dumpmodule pyopencvext _get_ext.py : : test_ext ;
def link (self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): # generate file 'Jamroot' f = open('Jamroot', 'wt') f.write('''
import pyopencvext as _P
import dumpmodule as _P
def link (self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): # generate file 'Jamroot' f = open('Jamroot', 'wt') f.write('''
_D.copy_file(_P.__file__, '%s')
_D.copy_file(_P.__file__.replace('dumpmodule', 'pyopencvext'), '%s')
def link (self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): # generate file 'Jamroot' f = open('Jamroot', 'wt') f.write('''
z.constructors(lambda x: 'Mat' in x.decl_string).exclude()
z.constructors(lambda x: len(x.arguments) > 1).exclude() z.mem_funs(lambda x: 'CvMat' in x.decl_string).exclude()
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z.mem_fun(lambda x: t==x.name and 'CvMat' in x.decl_string)._transformer_kwds['alias'] = t z.decls(lambda x: 'cv::Mat' in x.decl_string).exclude() z.add_wrapper_code(''' CvNormalBayesClassifier_wrapper(cv::Mat const & _train_data, cv::Mat const & _responses, cv::Mat const _var_idx, cv::Mat const & _sample_idx ) : CvNor...
for t2 in z.mem_funs(t): t2._transformer_kwds['alias'] = t z.add_wrapper_code(''' CvNormalBayesClassifier_wrapper(::cv::Mat const & _train_data, ::cv::Mat const & _responses, ::cv::Mat const & _var_idx=cv::Mat(), ::cv::Mat const & _sample_idx=cv::Mat() ) : CvNormalBayesClassifier() , bp::wrapper< CvNormalBayesClassifie...
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
idx = int(hierarchy[hierarchy[hierarchy[0][0]][0]][0])
idx = int(hierarchy[hierarchy[hierarchy[0,0],0],0])
def on_trackbar(pos, param): cnt_img = Mat(Size(w, w), CV_8UC3) cnt_img.setTo(0) if pos <= 3: idx = int(hierarchy[hierarchy[hierarchy[0][0]][0]][0]) max_level = 3-pos else: idx = -1 max_level = pos-3 drawContours( cnt_img, contours, idx, CV_RGB(255,0,0), CV_FILLED, 8, hierarchy, max_level ) imshow( "contours", cnt_im...
contours = [approxPolyDP(Mat(x), 3, 1) for x in contours]
contours = [approxPolyDP(Mat.from_ndarray(x.reshape(1,len(x),2)), 3, 1) for x in contours]
def generate_image(): img = Mat(Size(w,w), CV_8UC1) img.setTo(0) for i in range(6): dx = (i%2)*250 - 30 dy = (i/2)*150 white = Scalar(255) black = Scalar(0) if i==0: for j in range(11): angle = (j+5)*CV_PI/21 line(img, Point(round(dx+100+j*10-80*cos(angle)), round(dy+100-90*sin(angle))), Point(round(dx+100+j*10-30*co...
h = hierarchy[:].reshape(hierarchy.cols, 4) idx = int(h[h[h[0,0],0],0])
h = [x[0] for x in hierarchy] idx = int(h[h[h[0]]])
def on_trackbar(pos, param): cnt_img = Mat(Size(w, w), CV_8UC3) cnt_img.setTo(0) if pos <= 3: h = hierarchy[:].reshape(hierarchy.cols, 4) idx = int(h[h[h[0,0],0],0]) max_level = 3-pos else: idx = -1 max_level = pos-3 drawContours( cnt_img, contours, idx, CV_RGB(255,0,0), CV_FILLED, 8, hierarchy, max_level ) imshow( "...
contours = [approxPolyDP_int(x, 3, 1) for x in contours]
contours = vector_vector_Point2i([approxPolyDP_int(asMat(x), 3, 1) for x in contours])
def generate_image(): img = Mat(Size(w,w), CV_8UC1) img.setTo(0) for i in range(6): dx = (i%2)*250 - 30 dy = (i/2)*150 white = Scalar(255) black = Scalar(0) if i==0: for j in range(11): angle = (j+5)*CV_PI/21 line(img, Point(round(dx+100+j*10-80*cos(angle)), round(dy+100-90*sin(angle))), Point(round(dx+100+j*10-30*co...
z.mem_funs(lambda x: 'cv::Mat' in x.decl_string).exclude()
z.mem_funs(lambda t: '::CvMat const *' in t.decl_string).exclude()
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z.mem_fun(lambda x: x.name==t and 'CvMat' in x.decl_string)._transformer_kwds['alias'] = t
for t2 in z.mem_funs(t): t2._transformer_kwds['alias'] = t
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
CvSVM_wrapper(::cv::Mat const & _train_data, ::cv::Mat const & _responses, ::cv::Mat const & _var_idx, ::cv::Mat const & _sample_idx, ::CvSVMParams _params ) : CvSVM( &(::CvMat)(_train_data), &(::CvMat)(_responses), &(::CvMat)(_var_idx), &(::CvMat)(_sample_idx), _params ) , bp::wrapper< CvSVM >(){ }
CvSVM_wrapper(::cv::Mat const & _train_data, ::cv::Mat const & _responses, ::cv::Mat const & _var_idx=cv::Mat(), ::cv::Mat const & _sample_idx=cv::Mat(), ::CvSVMParams _params=::CvSVMParams( ) ) : CvSVM() , bp::wrapper< CvSVM >(){ // constructor train( _train_data, _responses, _var_idx, _sample_idx, _params ); }
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z.add_registration_code('def( bp::init< cv::Mat const &, cv::Mat const &, cv::Mat const &, cv::Mat const &, CvSVMParams >(( bp::arg("_train_data"), bp::arg("_responses"), bp::arg("_var_idx")=cv::Mat(), bp::arg("_sample_idx")=cv::Mat(), bp::arg("_params")=::CvSVMParams( ) )) )')
z.add_registration_code('def( bp::init< cv::Mat const &, cv::Mat const &, bp::optional< cv::Mat const &, cv::Mat const &, CvSVMParams > >(( bp::arg("_train_data"), bp::arg("_responses"), bp::arg("_var_idx")=cv::Mat(), bp::arg("_sample_idx")=cv::Mat(), bp::arg("_params")=::CvSVMParams( ) )) )')
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
idx = hierarchy[idx][0]
idx = int(hierarchy[idx][0])
def on_mouse( event, x, y, flags, param ): global prev_pt if img.empty(): return; if( event == CV_EVENT_LBUTTONUP or not (flags & CV_EVENT_FLAG_LBUTTON) ): prev_pt = Point(-1,-1) elif( event == CV_EVENT_LBUTTONDOWN ): prev_pt = Point(x,y) elif( event == CV_EVENT_MOUSEMOVE and (flags & CV_EVENT_FLAG_LBUTTON) ): pt = Poi...
z.constructors(lambda x: len(x.arguments) > 1).exclude() for t in ('train', 'find_nearest'):
z.constructors(lambda x: 'CvMat' in x.decl_string).exclude() for t in ('find_nearest', 'train'):
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z1 = z.mem_fun(lambda x: x.name=='train' and 'CvMat' in x.decl_string) z1.include() z1._transformer_kwds['alias'] = 'train' z.mem_funs('find_nearest').exclude()
t = z.mem_fun(lambda x: x.name=='train' and not 'CvMat' in x.decl_string) t.include() t._transformer_kwds['alias'] = 'train'
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
CvKNearest_wrapper( cv::Mat const & _train_data, cv::Mat const & _responses, cv::Mat const & _sample_idx, bool _is_regression, int max_k ) : CvKNearest( &(::CvMat)(_train_data), &(::CvMat)(_responses), _sample_idx.empty()? 0: &(::CvMat)_sample_idx, _is_regression, max_k ) , bp::wrapper< CvKNearest >() { }
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z.add_registration_code('def( bp::init< cv::Mat const &, cv::Mat const &, cv::Mat const &, bool, int >(( bp::arg("_train_data"), bp::arg("_responses"), bp::arg("_sample_idx")=cv::Mat(), bp::arg("_is_regression")=false, bp::arg("max_k")=32 )) )')
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
cv.line( correspond, cv.asPoint(pair[0]), cv.Point(int(pair[1].x), int(pair[1].y+object.rows)), colors[8] )
print pair cv.line( correspond, cv.asPoint(inst_Point2f=pair[0]), cv.Point(int(pair[1].x), int(pair[1].y+object.rows)), colors[8] )
def locatePlanarObject(ptpairs, src_corners, dst_corners): n = len(ptpairs) if n < 4: return 0 pt1 = cv.asMat([pair[0] for pair in ptpairs]) pt2 = cv.asMat([pair[1] for pair in ptpairs]) h = cv.findHomography(pt1, pt2, method=cv.RANSAC, ransacReprojThreshold=5)[:] for i in range(4): x = src_corners[i].x y = src_corne...
cv.circle(object_color, cv.asPoint(keypt.pt), int(keypt.size*1.2/9.*2), colors[0], 1, 8, 0)
cv.circle(object_color, cv.asPoint(inst_Point2f=keypt.pt), int(keypt.size*1.2/9.*2), colors[0], 1, 8, 0)
def locatePlanarObject(ptpairs, src_corners, dst_corners): n = len(ptpairs) if n < 4: return 0 pt1 = cv.asMat([pair[0] for pair in ptpairs]) pt2 = cv.asMat([pair[1] for pair in ptpairs]) h = cv.findHomography(pt1, pt2, method=cv.RANSAC, ransacReprojThreshold=5)[:] for i in range(4): x = src_corners[i].x y = src_corne...
for t2 in z.mem_funs(t): t2._transformer_kwds['alias'] = t
z.mem_fun(lambda x: x.name==t and not 'CvMat' in x.decl_string)._transformer_kwds['alias'] = t
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z.constructors(lambda x: len(x.arguments) > 1).exclude() z.mem_funs(lambda x: 'cv::Mat' in x.decl_string).exclude()
z.constructors(lambda x: 'CvMat' in x.decl_string).exclude() z.mem_funs(lambda x: 'CvMat' in x.decl_string).exclude()
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z.mem_fun(lambda x: x.name==t and 'CvMat' in x.decl_string)._transformer_kwds['alias'] = t z.add_wrapper_code(''' CvEM_wrapper( cv::Mat const & samples, cv::Mat const & sample_idx, CvEMParams params, cv::Mat const & labels ) : CvEM( &(::CvMat)samples, &(::CvMat)sample_idx, params, &(::CvMat)labels ) , bp::wrapper< CvEM...
z.mem_fun(lambda x: x.name==t and not 'CvMat' in x.decl_string)._transformer_kwds['alias'] = t
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z = mb.class_('CvDTreeSplit') mb.init_class(z) FT.expose_member_as_pointee(z, 'next') for t in ('subset', 'c', 'split_point'): z.var(t).exclude() mb.finalize_class(z)
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
z = mb.class_('CvDTreeNode') for t in ('parent', 'left', 'right', 'split'): FT.expose_member_as_pointee(z, t) for t in ('num_valid', 'cv_Tn', 'cv_node_risk', 'cv_node_error'): z.var(t).exclude() z = mb.class_('CvDTreeParams') z.include()
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
mat_contour = Mat(contour)
mat_contour = asMat(contour)
def findSquares4( img, thresh ): N = 11 sz = Size( img.cols & -2, img.rows & -2 ) timg = img.clone() # make a copy of input image gray = Mat(sz, CV_8UC1) pyr = Mat( Size(int(sz.width/2), int(sz.height/2)), CV_8UC3 ) # create empty sequence that will contain points - # 4 points per square (the square's vertices) squares...
mat_result = Mat(result)
mat_result = asMat(result)
def findSquares4( img, thresh ): N = 11 sz = Size( img.cols & -2, img.rows & -2 ) timg = img.clone() # make a copy of input image gray = Mat(sz, CV_8UC1) pyr = Mat( Size(int(sz.width/2), int(sz.height/2)), CV_8UC3 ) # create empty sequence that will contain points - # 4 points per square (the square's vertices) squares...
squares.append(result)
squares.append([asPoint(x) for x in result])
def findSquares4( img, thresh ): N = 11 sz = Size( img.cols & -2, img.rows & -2 ) timg = img.clone() # make a copy of input image gray = Mat(sz, CV_8UC1) pyr = Mat( Size(int(sz.width/2), int(sz.height/2)), CV_8UC3 ) # create empty sequence that will contain points - # 4 points per square (the square's vertices) squares...
z.constructors(lambda x: len(x.arguments) > 1).exclude()
def _KLASS__repr__(self): return "KLASS(min_val=" + repr(self.min_val) + ", max_val=" + repr(self.max_val) \ + ", step=" + repr(self.step) + ")"
doc_list_of_MatND(self.function, self.arg)
doc_list_of_Mat(self.function, self.arg)
def __configure_sealed( self, controller ): w_arg = controller.find_wrapper_arg(self.arg.name) w_arg.type = _D.dummy_type_t( "sdcpp::sequence" ) # intermediate variable vec = controller.declare_variable(_D.dummy_type_t("std::vector< %s >" % self.elem_type_str), self.arg.name) # pre_call controller.add_pre_call_code("...
doc_list_of_Mat(self.function, self.arg)
doc_list_of_MatND(self.function, self.arg)
def __configure_sealed( self, controller ): w_arg = controller.find_wrapper_arg(self.arg.name) w_arg.type = _D.dummy_type_t( "sdcpp::sequence" ) # intermediate variable vec = controller.declare_variable(_D.dummy_type_t("std::vector< %s >" % self.elem_type_str), self.arg.name) # pre_call controller.add_pre_call_code("...
bp::objects::make_nurse_and_patient(result.ptr(), inst_ELEM_NAME.ptr());
result.attr("_depends") = inst_ELEM_NAME;
def expose_class_Ptr(self, klass_name, ns=None): if ns is None: full_klass_name = klass_name else: full_klass_name = '%s::%s' % (ns, klass_name) z = self.class_('Ptr<%s>' % full_klass_name) common.register_ti('cv::Ptr', [full_klass_name]) mb.init_class(z) # constructor Ptr(_obj) needs to keep a reference of '_obj' z.co...
asClass2(self, src_class.alias, src_class.name, dst_class.alias, dst_class.name)
asClass2(self, src_class.alias, src_class.partial_decl_string, dst_class.alias, dst_class.partial_decl_string)
def asClass(self, src_class, dst_class): asClass2(self, src_class.alias, src_class.name, dst_class.alias, dst_class.name) src_class.operators(lambda x: dst_class.name in x.name).exclude()
ox = int(name[-2]) oy = int(name[-1]) cx = item.pos().toPoint().x()/(PIECESIZE+1) cy = item.pos().toPoint().y()/(PIECESIZE+1)
ox = float(name[-2]) oy = float(name[-1]) cx = item.pos().x()/(PIECESIZE+1) cy = item.pos().y()/(PIECESIZE+1)
def check(self): for item in self.scene().items(): name = item.objectName() ox = int(name[-2]) oy = int(name[-1]) cx = item.pos().toPoint().x()/(PIECESIZE+1) cy = item.pos().toPoint().y()/(PIECESIZE+1)
super(Piece, self).mousePressEvent(event)
def mousePressEvent(self, event): blank = self.findBlank() if blank: blank_len = blank.sum() curr_len = self.sum() self.swap(blank, True) if abs(curr_len-blank_len) % 2 == 0: global check if check == 0: check = 1 elif check == 1: check = 0
def init(geni_username, vesselcount, vesseltype, program_filename, *args):
def init(geni_username, vesselcount, vesseltype, program_filename):
def init(geni_username, vesselcount, vesseltype, program_filename, *args): """ <Purpose> Initializes the deployment of an arbitrary service. Populates a global configuration dictionary and returns a dict of data that could be required by the run() function. init() must be called before the run() function. Note on the ...
*args [Optional] Any additional arguments will be passed to the program deployed on vessels.
def init(geni_username, vesselcount, vesseltype, program_filename, *args): """ <Purpose> Initializes the deployment of an arbitrary service. Populates a global configuration dictionary and returns a dict of data that could be required by the run() function. init() must be called before the run() function. Note on the ...
return app(environ, start_response)
environ_copy = environ.copy() return app(environ_copy, start_response)
def __call__(self, environ, start_response): if self.template: template = self.remote_uri_template remote_uri = template % environ else: remote_uri = self.remote_uri
tasktracker = CustomDeliveranceMiddleware(tasktracker, FileRuleGetter(deliverance_ruleset))
tasktracker = CustomDeliveranceMiddleware( tasktracker, FileRuleGetter(deliverance_ruleset), default_theme=theme_uri)
def factory(loader, global_conf, **local_conf): default_app = local_conf['opencore'] default_app = loader.get_app(default_app) default_app = App(default_app, '') tasktracker = local_conf['tasktracker'] tasktracker = loader.get_app(tasktracker) deliverance_ruleset = local_conf['.deliverance_rule_file'] tasktracker = ...
FileRuleGetter(deliverance_ruleset))
FileRuleGetter(deliverance_ruleset), default_theme=theme_uri)
def factory(loader, global_conf, **local_conf): default_app = local_conf['opencore'] default_app = loader.get_app(default_app) default_app = App(default_app, '') tasktracker = local_conf['tasktracker'] tasktracker = loader.get_app(tasktracker) deliverance_ruleset = local_conf['.deliverance_rule_file'] tasktracker = ...
def match_path_info(self, path_info, script_name):
def match_path_info(self, script_name, path_info): """ Determines if the given URL matches one of the apps registered with the dispatcher. If there is a match, the caller will want to modify SCRIPT_NAME and PATH_INFO before passing the request to the matching application. So we return a rewritten SCRIPT_NAME and PATH_...
def match_path_info(self, path_info, script_name): for path in self.apps: if path_info == path or path_info.startswith(path+'/'): script_name += path path_info = path_info[len(path):] assert not path_info or path_info.startswith('/') return (self.apps[path], path_info, script_name)
return (self.apps[path], path_info, script_name)
return (self.apps[path], script_name, path_info)
def match_path_info(self, path_info, script_name): for path in self.apps: if path_info == path or path_info.startswith(path+'/'): script_name += path path_info = path_info[len(path):] assert not path_info or path_info.startswith('/') return (self.apps[path], path_info, script_name)
return (False, path_info, script_name)
return (None, script_name, path_info)
def match_path_info(self, path_info, script_name): for path in self.apps: if path_info == path or path_info.startswith(path+'/'): script_name += path path_info = path_info[len(path):] assert not path_info or path_info.startswith('/') return (self.apps[path], path_info, script_name)
app_to_dispatch_to, new_path_info, new_script_name = \ self.match_path_info(new_path_info, new_script_name)
app_to_dispatch_to, new_script_name, new_path_info = \ self.match_path_info(new_script_name, new_path_info)
def __call__(self, environ, start_response): project, new_script_name, new_path_info = parse_project(environ) if not project: # we are not in a project context, so we'll just let the # default app (opencore) deal with the request. return self.default_app(environ, start_response)
new_path_info, new_script_name)
new_path_info.lstrip('/'), new_script_name.rstrip('/'))
def __call__(self, environ, start_response): project, new_path_info, new_script_name = parse_project(environ) if not project: return self.default_app(environ, start_response)
app = RemoteProxy(remote_uris, is_opencore, robots_uri=robots_uri)
app = RemoteProxy(remote_uris, is_opencore, robots_uri=robots_uri, site_root=site_root)
def app_factory(global_conf, remote_uri=None, is_opencore=False, is_twirlip=None, robots_uri=None, **local_conf): assert remote_uri is not None remote_uris = [i.strip() for i in remote_uri.split() if i.strip()] app = RemoteProxy(remote_uris, is_opencore, robots_uri=robots_uri) if is_twirlip is None: return app # if we...
def __init__(self, remote_uris=None, is_opencore=False, robots_uri=None):
def __init__(self, remote_uris=None, is_opencore=False, robots_uri=None, site_root=None):
def __init__(self, remote_uris=None, is_opencore=False, robots_uri=None): remote_uris = remote_uris or []
def make_featurelet(loader, section, theme_uri, rules): app = loader.get_app(section)
def make_featurelet(app, theme_uri, ruleset, app_name):
def make_featurelet(loader, section, theme_uri, rules): app = loader.get_app(section) app = CustomDeliveranceMiddleware( app, FileRuleGetter(deliverance_ruleset), default_theme=theme_uri) tasktracker = App(tasktracker, 'tasktracker')
FileRuleGetter(deliverance_ruleset),
FileRuleGetter(ruleset),
def make_featurelet(loader, section, theme_uri, rules): app = loader.get_app(section) app = CustomDeliveranceMiddleware( app, FileRuleGetter(deliverance_ruleset), default_theme=theme_uri) tasktracker = App(tasktracker, 'tasktracker')
tasktracker = App(tasktracker, 'tasktracker')
app = App(app, app_name) return app
def make_featurelet(loader, section, theme_uri, rules): app = loader.get_app(section) app = CustomDeliveranceMiddleware( app, FileRuleGetter(deliverance_ruleset), default_theme=theme_uri) tasktracker = App(tasktracker, 'tasktracker')
tasktracker = make_featurelet(loader, tasktracker, theme_uri, deliverance_ruleset)
tasktracker = loader.get_app(tasktracker) tasktracker = make_featurelet(tasktracker, theme_uri, deliverance_ruleset, 'tasktracker')
def factory(loader, global_conf, **local_conf): default_app = local_conf['opencore'] default_app = loader.get_app(default_app) default_app = App(default_app, '') deliverance_ruleset = local_conf['.deliverance_rule_file'] theme_uri = local_conf['.theme_uri'] other_apps = [] tasktracker = local_conf.get('tasktracker')...
wordpress = make_featurelet(loader, wordpress, theme_uri, deliverance_ruleset)
wordpress = loader.get_app(wordpress) wordpress = make_featurelet(wordpress, theme_uri, deliverance_ruleset, 'wordpress')
def factory(loader, global_conf, **local_conf): default_app = local_conf['opencore'] default_app = loader.get_app(default_app) default_app = App(default_app, '') deliverance_ruleset = local_conf['.deliverance_rule_file'] theme_uri = local_conf['.theme_uri'] other_apps = [] tasktracker = local_conf.get('tasktracker')...
remote_uri=None, is_opencore=None
remote_uri=None, is_opencore=None,
def proxy_factory(global_conf, remote_uri=None, is_opencore=None **local_conf): return RemoteProxy(remote_uri, is_opencore)
macro_wrapper = ViewPageTemplateFile('macro_group_wrapper.pt', globals()).__of__(self)
macro_wrapper = ViewPageTemplateFile('macro_group_wrapper.pt')
def updateSearchGroup(self, type='', search_term=''): macro_wrapper = ViewPageTemplateFile('macro_group_wrapper.pt', globals()).__of__(self) mailservices = getMultiAdapter((self.context, self.request, ), name="mailservices")
res = macro_wrapper(the_macro=macro, instance=self.context, view=mailservices)
res = macro_wrapper(self, the_macro=macro, instance=self.context, view=mailservices)
def updateSearchGroup(self, type='', search_term=''): macro_wrapper = ViewPageTemplateFile('macro_group_wrapper.pt', globals()).__of__(self) mailservices = getMultiAdapter((self.context, self.request, ), name="mailservices")
macro_wrapper = ViewPageTemplateFile('macro_user_wrapper.pt', globals()).__of__(self)
macro_wrapper = ViewPageTemplateFile('macro_user_wrapper.pt')
def updateSearchUser(self, search_term=''): macro_wrapper = ViewPageTemplateFile('macro_user_wrapper.pt', globals()).__of__(self) mailservices = getMultiAdapter((self.context, self.request, ), name="mailservices")
res = macro_wrapper(the_macro=macro, instance=self.context, view=mailservices)
res = macro_wrapper(self, the_macro=macro, instance=self.context, view=mailservices)
def updateSearchUser(self, search_term=''): macro_wrapper = ViewPageTemplateFile('macro_user_wrapper.pt', globals()).__of__(self) mailservices = getMultiAdapter((self.context, self.request, ), name="mailservices")
sys.stderr.write ('Usage: sys.argv [0] text_source [chain_length=1]\n')
sys.stderr.write ('Usage: ' + sys.argv [0] + ' text_source [chain_length=1]\n')
def main (): if len (sys.argv) < 2: sys.stderr.write ('Usage: sys.argv [0] text_source [chain_length=1]\n') sys.exit (1) filename = sys.argv [1] global markovLength if len (sys.argv) == 3: markovLength = int (sys.argv [2]) buildMapping (wordlist (filename)) print genSentence ()
client.disconnect_callback = self._on_client_disconnect
if client.is_classicmode(): def on_got_methods(methods): """ Handles receiving the method names """ self._remote_methods = methods client.daemon.get_method_list().addCallback(on_got_methods) else: client.disconnect_callback = self._on_client_disconnect
def __init__(self): resource.Resource.__init__(self) component.Component.__init__(self, "JSON") self._remote_methods = [] self._local_methods = {} client.disconnect_callback = self._on_client_disconnect