def xmlToDict(xml): _dict = lists.HashedLists2() docs = [parseString(d) for d in xml.split('\x00')] for doc in docs: _data = doc.getElementsByTagName("data") for d in _data: _dict['data'] = getAttrsFromNode(d) _items = doc.getElementsByTagName("item") for item in _items: _item = lists.HashedLists2() _attrs = getAttrsFromNode(item) _key = '' if (_attrs.has_key('Id')): _key = _attrs['Id'] if (len(_key) > 0): for child in item.childNodes: _attrs = getAttrsFromNode(child) _text = getNodeText(child) if (len(_text) == 0): _text = getAllNodeText(child.childNodes) _item['attributes'] = _attrs _item[child.nodeName] = _text _dict[_key] = _item pass return _dict
def get_package_details(browser, _url, url, logging=None): import urllib2 req = urllib2.Request(url) req.add_header("Referer", url.split('?')[0]) browser.open(req) _d = lists.HashedLists2() form_attrs = [] for anchor in browser.links(): try: href = anchor.url toks = [[x.split('=') for x in tt] for tt in [t.split('&') for t in href.split('?')]] d = {} d[toks[0][0][0]] = dict([tuple(t) for t in toks[-1]]) if (d.has_key('/pypi')): dd = lists.HashedLists2(d['/pypi']) if (len(dd) > 1) and (((dd.has_key(':action')) and (dd[':action'] == 'submit_form')) or ((dd.has_key('%3Aaction')) and (dd['%3Aaction'] == 'submit_form'))): _datum = tuple([href, d, anchor.text]) url, d, details = _datum url = '%s%s' % (_url, url) return get_package_details2(browser, _url, url, logging=logging) except Exception as e: info_string = _utils.formattedException(details=e) pass return _d, form_attrs
def dedupeContacts(self, _contacts): from vyperlogix.hash import lists d = lists.HashedLists() for c in _contacts: d[c['Email']] = lists.HashedLists2(c) contacts = [] ascii_only = _utils.ascii_only for k, v in d.iteritems(): if (misc.isList(v)): assets = lists.HashedLists2() for item in v: try: for aKey in item.keys(): item[aKey] = ascii_only(item[aKey]) assets[item['Asset_Id']] = item['Asset_Name'] del item['Asset_Id'] del item['Asset_Name'] except Exception as details: info_string = _utils.formattedException( details=details) appendText(self.__child_frame.textboxLog, info_string) v[0]['Asset_Ids'] = ','.join( misc.sortCopy([item for item in list(set(assets.keys()))])) contacts.append(v[0]) else: try: for aKey in v.keys(): v[aKey] = ascii_only(v[aKey]) except: pass contacts.append(v) return contacts
def leadTypes(self): from vyperlogix.hash import lists d_leadTypes = lists.HashedLists2() r = self.getLeadSourceTypes() if (r): d_leadTypes = lists.HashedLists2( dict([(t['Id'], t['Name']) for t in r if (t.has_key('Id'))])) return d_leadTypes
def leadSourceDescriptions(self): from vyperlogix.hash import lists d_LeadSourceData_Descriptions = lists.HashedLists2() if (self.flds_LeadSourceData__c.has_key('Description__c')): d_LeadSourceData_Descriptions = lists.HashedLists2( self.flds_LeadSourceData__c['Description__c'] ['picklistValues']) return d_LeadSourceData_Descriptions
def _drill_into_Zone_Facet(self, url): self.request = urllib2.Request(url) self.request.add_header("Referer", self.referer) self.browser.open(self.request) c = self.browser.response().read() self.soup = BeautifulSoup.BeautifulSoup(c) self.forms = self.soup.findAll('form') self.d_newForm_actions = lists.HashedLists2() for f in self.forms: self.d_newForm = lists.HashedLists2() self.d_form = lists.HashedFuzzyLists2(dict(f.attrs)) if (self.d_form['name'] == 'add'): children = f.findChildren('input') for aChild in children: self.d_child = lists.HashedFuzzyLists2(dict(aChild.attrs)) self.d_newForm[ self.d_child['name']] = self.d_child['value'] action = self.d_form['action'] self.d_newForm_actions[self.d_form['name']] = action if (callable(self.callback_addForm)): try: self.callback_addForm(self, action=action) except: pass elif (self.d_form['name'] == 'edit'): children = f.findChildren('input') self.tuples = [] self.d_tuples = lists.HashedFuzzyLists2() elements = [] pattern = ['id', 'oldfrom', 'oldto', 'del'] p = [] for aChild in children: d_form = lists.HashedLists2(dict(aChild.attrs)) name = str(d_form['name']) if (pattern[len(p)] == name): elements.append(d_form) p.append(name) if (p == pattern): self.tuples.append(elements) oldfrom = [ e for e in elements if (e['name'] == 'oldfrom') ] oldto = [ e for e in elements if (e['name'] == 'oldto') ] if (len(oldfrom) == 1) and (len(oldto) == 1): self.d_tuples[oldfrom[0]['value']] = oldto[0][ 'value'], elements elements = [] p = [] action = self.d_form['action'] self.d_newForm_actions[self.d_form['name']] = action if (callable(self.callback_editForm)): try: self.callback_editForm(self, action=action) except: pass
def leadSourceTypes(self): from vyperlogix.hash import lists d_LeadSourceData_Types = lists.HashedLists2() if (self.flds_LeadSourceData__c.has_key('Type__c')): d_LeadSourceData_Types = lists.HashedLists2( self.flds_LeadSourceData__c['Type__c']['picklistValues']) l_retire = [] for k, v in d_LeadSourceData_Types.iteritems(): if (v['label'].find(' did not ') > -1) or (v['value'].find(' did not ') > -1): l_retire.append(k) #for k in l_retire: #del d_LeadSourceData_Types[k] return d_LeadSourceData_Types
def leadSources(self): from vyperlogix.hash import lists d_Lead = self.sfQuery.sfdc.describeSObject('Lead') flds_Lead = d_Lead.metadata['fields'] d_LeadSources = lists.HashedLists2() if (flds_Lead.has_key('LeadSource')): d_LeadSources = lists.HashedLists2( flds_Lead['LeadSource']['picklistValues']) l_retire = [] for k, v in d_LeadSources.iteritems(): if (v['active'] == False): l_retire.append(k) for k in l_retire: del d_LeadSources[k] return d_LeadSources
def instance_as_SmartObject(item): '''This function fails from time to time so fix it !''' from vyperlogix.classes.SmartObject import PyroSmartObject as SmartObject d = lists.HashedLists2( dict([(k, v) for k, v in item.__dict__.iteritems() if (not ObjectTypeName.type_is_class(v))])) return SmartObject(d)
def _getAccountTree_(self,account,tree=[],skip_ancestors=False): '''Walk-up the tree look for the account that has no parent then locate all children.''' try: if (account['ParentId'] is None): tree.append(account) ancestors = [] # There cannot be any ancestors because this account has no parent and this makes the account the progenitor by default. else: ancestors = self.getAccountAncestors(account,ancestors=[]) if (not skip_ancestors) and (len(ancestors) > 0): d_ancestors = lists.HashedLists2() for ancestor in ancestors: d_ancestors[ancestor['ParentId']] = ancestor progenitor = d_ancestors[None] if (lists.isDict(progenitor)) and (len([node for node in tree if (node['Id'] == progenitor['Id'])]) == 0): tree.append(progenitor) return self._getAccountTree_(progenitor,tree=tree,skip_ancestors=skip_ancestors) else: if (not lists.isDict(account)): return tree children = self.getAccountsByParentId(account['Id']) for child in children: if (lists.isDict(child)) and (len([node for node in tree if (node['Id'] == child['Id'])]) == 0): tree.append(child) self._getAccountTree_(child,tree=tree,skip_ancestors=True) except Exception as details: info_string = _utils.formattedException(details=details) print >>sys.stderr, info_string return tree
def edit_a_package(browser, _url, pkg, callback=None, logging=None): from vyperlogix.url._urllib2 import http_post_authenticated if (logging is not None): logging.info(pkg) else: print >> sys.stderr, pkg url, d, details = pkg dd = d[d.keys()[0]] if (dd.has_key('%3Aaction')) and (dd['%3Aaction'] == 'pkg_edit'): url = '%s%s' % (_url, url) d, form_attrs = get_package_details(_url, url, username, password, logging=logging) if (callable(callback)): try: callback(d) except: pass d_attrs = lists.HashedLists2(dict(form_attrs)) url = '%s%s' % (_url, d_attrs['action']) http_post_authenticated(url, d, username, password, logging=logging) info_string = 'Updated! (%s)' % (d['version']) if (logging is not None): logging.info(info_string) else: print >> sys.stderr, info_string print '=' * 80
def __init__(self, connection_string, classObj=None, tableDef=None, autoflush=True, autocommit=True, isMultiSession=False, non_primary=False): '''Usage: connection_string = "mysql://*****:*****@server-name=goes-here:3306/database-name-goes-here" http://www.sqlalchemy.org/docs/05/ormtutorial.html ''' self.__isMultiSession__ = isMultiSession self.__non_primary__ = non_primary self.__autoflush__ = autoflush self.__autocommit__ = autocommit self.__engine__ = create_engine(connection_string, pool_size=20, max_overflow=0) self.__classObj__ = classObj self.__tableDef__ = tableDef self.__agents = lists.HashedLists2() self.__mappers = [] self.__mapper__ = mapper( self.__classObj__, self.__tableDef__, non_primary=non_primary) if (self.__classObj__ is not None) and ( self.__tableDef__ is not None) else None if (self.__mapper__ is not None): self.__mappers.append(self.__mapper__) self.__session__ = None if (not self.__isMultiSession__): self.new_session() self.__lastError__ = ''
def __init__(self,mc_servers=['127.0.0.1:11211'],mc_debug=0): global __is_memcachable__ self.__mc_servers__ = mc_servers self.__mc_debug__ = mc_debug self.__d__ = lists.HashedLists2() if (__is_memcachable__): self.__memcache_client__ = memcache.Client(self.mc_servers, debug=self.mc_debug) __is_memcachable__ = all([s.connect() for s in self.__memcache_client__.servers])
def get_packages(browser, url, username, password, logging=None): '''Returns a list of items as follows: (u'/pypi?%3Aaction=logout', {u'/pypi': {u'%3Aaction': u'logout'}}, u'Logout') ''' import urllib2 from vyperlogix.url import _urllib2 browser.add_password(url, username, password) packages = [] try: req = urllib2.Request(url) req.add_header("Referer", url.split('?')[0]) browser.open(req) for aLink in browser.links(): d_attrs = lists.HashedFuzzyLists2(dict(aLink.attrs)) _href = d_attrs['href'] toks = _urllib2.parse_href_into_parms(_href)[-1] if (all([isinstance(t, list) for t in toks])): try: d_parms = lists.HashedFuzzyLists2( dict([tuple(t) for t in toks])) except: d_parms = lists.HashedFuzzyLists2() if ((d_parms[':action']) or (d_parms['%3Aaction'])) and (d_parms['name']): href = aLink.url text = aLink.text toks = [[x.split('=') for x in tt] for tt in [t.split('&') for t in href.split('?')]] d = lists.HashedLists2() d[toks[0][0][0]] = lists.HashedLists2( dict([tuple(t) for t in toks[-1]])) _datum = tuple([href, d, text]) dd = d[d.keys()[0]] if (dd is not None) and (misc.isString( str(dd['name']) if ( dd['name'] is not None) else dd['name'])): packages.append(_datum) except Exception as e: info_string = _utils.formattedException(details=e) if (logging is not None): logging.warning(info_string) print >> sys.stderr, info_string return packages
def d_parms(url_toks): from vyperlogix.hash import lists url_toks = url_toks if (misc.isList(url_toks)) else [] t = url_toks[1:] if (len(t) % 2 != 0): t.append('') return lists.HashedLists2(dict([tuple(t)]))
def normalizedSortedKeys(self, options=NormalizedKeyOptions.via_list): ''' Get a list of keys sorted in a fashion that allows for easier manipulation - padded or normalized to allow sorting to work. options = see also NormalizedKeyOptions enumeration ''' from vyperlogix.hash import lists try: _asDict = options.value & NormalizedKeyOptions.via_dict.value except: _asDict = False try: _useHash1 = options.value & NormalizedKeyOptions.use_hash1.value except: _asDict = False _useHash1 = False try: _useHash2 = options.value & NormalizedKeyOptions.use_hash2.value except: _useHash2 = False _useHash2 = ((not _useHash1) and (not _useHash2)) or _useHash2 _useHash1 = False if (_useHash1 and _useHash2) else _useHash1 d_keys = lists.HashedLists() if _useHash1 else lists.HashedLists2( ) if _useHash2 else {} def normalizeKey(k, m): toks = k.split(',') n = toks[0] del toks[0] getLen = lambda m, n: m - len(n) formatter = lambda p, m, n, f: p % (' ' * getLen(m, n), f(n)) _value = '' _isString = (misc.isString(n)) _pattern = '%s%s' if _isString else '%s%d' _func = str if _isString else int _value = formatter(_pattern, m, n, _func) toks.insert(0, _value) s = ','.join(toks) if (_asDict): d_keys[s] = k return s l_keys = [len(k.split(',')[0]) for k in self.keys()] l_keys.sort() _max_len = l_keys[-1] if len(l_keys) > 0 else 0 _keys = [normalizeKey(k, _max_len) for k in self.keys()] _keys.sort() _keys.reverse() return _keys if (not _asDict) else d_keys
def getAccountContacts(self, accountId, reExclude_AccountName=None): _contacts = [] if (accountId is not None) and (len(accountId) > 0): soql = "Select c.Email, c.FirstName, c.Full_Name__c, c.HasOptedOutOfEmail, c.Id, c.LastName, c.MailingCity, c.MailingCountry, c.MailingPostalCode, c.MailingState, c.MailingStreet, c.OtherCity, c.OtherCountry, c.OtherPhone, c.OtherPostalCode, c.OtherState, c.OtherStreet from Contact c WHERE (c.HasOptedOutOfEmail = False) and (c.AccountId = '%s')" % ( accountId) contacts = self.sf_query(soql) if (contacts): for c in contacts: d = lists.HashedLists2(c) _contacts.append(d) return _contacts
def render_captcha_form(request, form_name=None, font_name=None, font_size=18, choices='QWERTYPASDFGHJKLZXCVBNM23456789', fill=(255, 255, 255), bgImage='bg.jpg'): try: imghash = '' tempname = '' imgtext = '' try: from random import choice import Image, ImageDraw, ImageFont, sha _settings = django_utils.get_from_session( request, 'settings', default=lists.HashedLists2()) if (not _settings.has_key('SECRET_KEY')): from django.conf import settings as _settings SALT = _settings.SECRET_KEY[:20] imgtext = ''.join([choice(choices) for i in range(5)]) imghash = sha.new(SALT + imgtext).hexdigest() image_fname = os.path.join(_settings.MEDIA_ROOT, bgImage) im = Image.open(image_fname) draw = ImageDraw.Draw(im) font_fname = os.path.join(_settings.MEDIA_ROOT, font_name) font = ImageFont.truetype(font_fname, font_size) draw.text((10, 10), imgtext, font=font, fill=fill) _captcha_symbol = 'captcha' image_name = '%s.jpg' % (imgtext) temp = os.path.join(_settings.MEDIA_ROOT, _captcha_symbol, image_name) _utils._makeDirs(os.path.dirname(temp)) tempname = '/'.join( [_settings.MEDIA_URL, _captcha_symbol, image_name]) if (os.path.exists(tempname)): os.remove(tempname) im.save(temp, "JPEG") except: imghash = '' tempname = '' imgtext = '' except Exception as e: return _utils.formattedException(details=e) if (misc.isString(form_name)): c = {'hash': imghash, 'tempname': tempname} http_host = django_utils.get_http_host(request).split(':')[0] if (django_utils.isBeingDebugged(http_host)): c['imgtext'] = imgtext ctx = Context(c, autoescape=False) return render_to_string(form_name, context_instance=ctx) else: return render_to_string('405.html', {})
def dictFromSOQL(self, ret): d = lists.HashedLists2() try: for k in ret.keys(): v = ret[k] for vk in v.keys(): d[vk] = v[vk] except Exception as details: from vyperlogix.misc import _utils info_string = _utils.formattedException(details=details) logging.warning(info_string) return d
def calcXferRate(xfer_rate): xfer_factor = 1 xfer_rate_calc = xfer_rate / 1024 xfer_rate_fmt = '%s KB/sec' % ('%-4.2f' % xfer_rate_calc).strip() if (xfer_rate_calc > 1024): xfer_factor = 1024 xfer_rate_calc = xfer_rate / (1024 * xfer_factor) xfer_rate_fmt = '%s MB/sec' % ('%-4.2f' % xfer_rate_calc).strip() return lists.HashedLists2({ 'xfer_rate': xfer_rate, 'xfer_factor': xfer_factor, 'xfer_rate_fmt': xfer_rate_fmt })
def __init__(self, request, name, model, action, target='_top'): self.__model_choice_fields = lambda self: [ field for field in [self.fields[k] for k in self.fields.keyOrder] if self.is_ModelChoiceField(field) ] self.__model__ = model self.__form_name__ = name self.__target__ = target self.__action__ = action self.__request__ = request self.__datasources__ = lists.HashedLists2( ) # datasource specifies the source of data for any given field name. self.__fields__ = fields.fields_for_model(model) self.__model_choice_fields__ = self.__model_choice_fields(self) self.__d_model_choice_fields__ = lists.HashedFuzzyLists2() for field in self.__model_choice_fields__: self.__d_model_choice_fields__[field.label] = field self.__choice_models__ = lists.HashedLists2() self.__choice_model_defaults__ = lists.HashedLists2() self.__last_error__ = '' self.__use_captcha__ = False self.__captcha_form_name__ = None self.__captcha_font_name__ = None self.__captcha_font_size__ = 18 self.__captcha_choices__ = ''.join( chr(ch) for ch in xrange(ord('A'), ord('Z') + 1)) self.__captcha_fill__ = (255, 255, 255) self.__captcha_bgImage__ = 'bg.jpg' self.__get_freehost_by_name__ = None self.__datetime_field_content__ = '' self.__submit_button_title__ = 'Submit Button Title' self.__submit_button_value__ = 'Submit Button Value' self.__field_validations__ = [ ] # list of tuples where first element is a lambda and the second element is a dict that connects context elements to error messages when validation fails. self.__hidden_fields__ = lists.HashedLists2() self.__field_ordering__ = [ ] # list of field names to be used to render the fields as HTML. self.__extra_fields__ = lists.HashedLists2()
def execDaemon(f, dpath=None, _logging=None): _import_error = False try: exec "import " + f except ImportError: _import_error = True exc_info = sys.exc_info() info_string = '\n'.join(traceback.format_exception(*exc_info)) if (_logging): _logging.error(info_string) else: print >> sys.stderr, info_string info_string = '_import_error=%s' % _import_error if (_logging): _logging.warning(info_string) else: print >> sys.stderr, info_string if (not _import_error): _metadata[f] = lists.HashedLists2() try: v = '%s._metadata' % (f) vv = eval(v) print '%s=[%s]' % (v, vv) _metadata[f] = lists.HashedLists2(vv) v = '%s.data_hook("%s")' % (f, dpath if (sys.platform[:3] != 'win') else dpath.replace(os.sep, '/')) vv = eval(v) print '%s=[%s]' % (v, vv) except AttributeError: pass except ImportError: exc_info = sys.exc_info() info_string = '\n'.join(traceback.format_exception(*exc_info)) if (_logging): _logging.error(info_string) else: print >> sys.stderr, info_string
def getComputerSystem(): import wmi from vyperlogix.hash import lists d = lists.HashedLists2() try: computer = wmi.WMI() blah = computer.Win32_ComputerSystem()[0] for name in blah._properties: d[name] = eval('blah.%s' % (name)) except: pass return d
def reorder(self): _root = ProcessNode(["root",-1,-1]) d = lists.HashedLists2() for node in self.root.preOrder(): d[node.parentId] = node l = misc.sort(d.keys()) for i in l: if (i > -1): _root._addChild(ProcessNode([d[i].procName,d[i].procId,d[i].parentId])) for node in self.root.preOrder(): if (node.procId not in l): _root._addChild(node) self.root = _root return self.root
def get_package_details2(browser, _url, url, logging=None): import urllib2 from vyperlogix.misc import ObjectTypeName from vyperlogix import misc req = urllib2.Request(url) req.add_header("Referer", url.split('?')[0]) browser.open(req) d = lists.HashedLists2() _forms = [] for form in browser.forms(): elements = form.controls _forms.append(tuple([len(elements), elements])) d_forms = dict(_forms) keys = misc.sort(d_forms.keys()) elements = d_forms[keys[-1]] if (len(elements) > 0): inputs = [ c for c in [(ele, ObjectTypeName.typeClassName(ele)) for ele in elements] if (c[-1].find('ClientForm.') > -1) and ( c[-1] not in ['ClientForm.SubmitControl']) ] for item in inputs: ele, cname = item d_attrs = ele.attrs if (cname == 'ClientForm.SelectControl'): choice = [ choice for choice in ele.get_items() if (choice._selected) ] d[d_attrs['name']] = ','.join([ a['label'] for a in [ choice.attrs for choice in ele.get_items() if (choice._selected) ] ]) elif (cname == 'ClientForm.TextareaControl'): for p in ele.pairs(): d[p[0]] = p[-1] else: try: d[d_attrs['name']] = d_attrs['value'] except Exception as e: info_string = _utils.formattedException(details=e) pass return d, form.attrs return d, []
def _collectFromPath(fpath,option=PathCollectionOptions.collect_files,rejecting_re=None): '''See the PathCollectionOptions for the details.''' import os import logging from vyperlogix.hash import lists d_files = lists.HashedLists2() if (os.path.exists(fpath)): for root, dirs, files in _utils.walk(fpath, topdown=True, rejecting_re=rejecting_re): if (option.value == PathCollectionOptions.collect_files.value): for f in files: _fname = os.sep.join([root,f]) d_files[_fname] = _fname elif (option.value == PathCollectionOptions.collect_dirs.value): d_files[root] = dirs return d_files
def post_from_sqlalchemy(request): d = lists.HashedLists() for k, v in request.POST.iteritems(): toks = k.split('-') _d_ = d for t in toks[0:-1]: _d = _d_[t] if (_d is None): _d = lists.HashedLists2() _d_[t] = _d else: _d = _d[0] if (misc.isList(_d)) else _d _d_ = _d _d_[toks[-1]] = v[0] if (misc.isList(v)) else v return d
def __init__(self, name, locals={}, globals=None): """ Create a LazyImport instance wrapping module name. The module will later on be registered in locals under the given module name. globals is optional and defaults to locals. """ self.__dict__ = lists.HashedLists2(self.__dict__) self.__lazyimport_locals = lists.HashedLists2(locals) if (globals is None): globals = lists.HashedLists2(locals) elif (lists.isDict(globals)): globals = lists.HashedLists2(globals) self.__lazyimport_globals = globals mainname = globals.get('__name__', '') if (globals.has_key('__name__')) else None if (mainname): self.__name__ = mainname + '.' + name self.__lazyimport_name = name else: self.__name__ = self.__lazyimport_name = name self.__lazyimport_init = 1
def is_captcha_form_valid(request): import sha if request.POST: data = request.POST.copy() _settings = django_utils.get_from_session(request, 'settings', default=lists.HashedLists2()) if (not _settings.has_key('SECRET_KEY')): from django.conf import settings as _settings SALT = _settings.SECRET_KEY[:20] try: return data['imghash'] == sha.new(SALT + data['imgtext']).hexdigest() except: return False return False
def sftp_to_host(hostname, username, password, source, dest, isSilent=False): try: ssh = SSHConnection(hostname=hostname, username=username, password=password) except: exc_info = sys.exc_info() info_string = _utils.asMessage('\n'.join( traceback.format_exception(*exc_info))) print >> sys.stderr, info_string if (not isSilent): print 'ssh.transport = %s' % (ssh.transport) if (ssh.transport): results = [0, -1] try: if (not isSilent): print 'ssh.isdir(%s)=%s' % (dest, ssh.isdir(dest)) if (ssh.isdir(dest)): dest = ssh.sep.join([dest, os.path.basename(source)]) if (not isSilent): print 'dest=%s' % (dest) print 'ssh.exists(%s)=%s' % (dest, ssh.exists(dest)) if (ssh.exists(dest)): if (not isSilent): print 'ssh.remove(%s)' % (dest) ssh.remove(dest) if (not isSilent): print 'SFTP "%s" to host as "%s".' % (source, dest) results = ssh.put(source, dest, callback=giveXferStatus if (not isSilent) else None) except: exc_info = sys.exc_info() info_string = _utils.asMessage('\n'.join( traceback.format_exception(*exc_info))) print >> sys.stderr, info_string finally: xfer_rate_calc = lists.HashedLists2() if ( results is None) else calcXferRate(results[-1]) if (not isSilent): print 'SFTP Done, %s, Closing Connection.' % ( xfer_rate_calc['xfer_rate_fmt']) ssh.close() else: print >> sys.stderr, 'Unable to get a connection with the server using "%s".' % ( '%s,%s,%s' % (hostname, username, password))