Posts

python - How do I to turn my .tar.gz file into a file-like object for shutil.copyfileobj? -

my goal extract file out of .tar.gz file without extracting out sub directories precede desired file. trying module method off question . asked question of own seemed answer thought work didn't work fully. in short, shutil.copyfileobj isn't copying contents of file. my code now: import os import shutil import tarfile import gzip tarfile.open('rtlog_20150425t152948.gz', 'r:*') tar: member in tar.getmembers(): filename = os.path.basename(member.name) if not filename: continue source = tar.fileobj target = open('out', "wb") shutil.copyfileobj(source, target) upon running code file out created however, file empty. know file wanted extract does, in fact, have lots of information (approximately 450 kb). print(member.size) returns 1564197 . my attempts solve unsuccessful. print(type(tar.fileobj)) told me tar.fileobj <gzip _io.bufferedreader name='rtlog_20150425t15294...

android - Glide + CollapsingToolbarLayout strange behavior -

Image
i'm facing strange behavior when using collapsingtoolbarlayout, toolbar , imageview embedded. here code : <android.support.design.widget.appbarlayout android:id="@+id/bla" android:layout_width="match_parent" android:layout_height="256dp"> <android.support.design.widget.collapsingtoolbarlayout android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollflags="scroll|exituntilcollapsed"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="@color/md_white_1000" android:minheight="?attr/actionbarsize" app:layout_collapsemode="pin" ...

excel vba - How to delete the blank sheets in the given workbook? -

sub deleteemptysheets() dim sh worksheet, wb workbook, c range sh = sheets(wb.sheets) each c in wb.sheets if isempty(sh.usedrange) sh.delete end if next set sh = nothing set wb = nothing set c = nothing end sub question:i tried delete empty sheets, not able exact code. can me in case? thanks. you're not defining wb comes from, , you're not using sh iterate through sheets. i'm assuming want iterate through sheets in active workbook. if so, don't need wb or c . try this: sub deleteemptysheets() dim sh worksheet each sh in activeworkbook.sheets if isempty(sh.usedrange) sh.delete end if next set sh = nothing end sub

java - How do I define the toString in this program. It is supposed to return the super hero based on the favorite color -

i need finish programming assignment in 1 hour. have done of it, cannot understand how complete tostring @ end. program find users favorite super hero. here driver class /* * change license header, choose license headers in project properties. * change template file, choose tools | templates * , open template in editor. */ package superherotester; import java.util.scanner; /** * * @author charters */ public class superherotester { public static superhero asuperhero; /** * program */ public static void main(string[] args) { getdatafromuser(); determinesuperheroidentity(); } public static void getdatafromuser() { scanner keyboard = new scanner(system.in); system.out.println("what first name?"); string firstname = keyboard.nextline(); system.out.println("what last name?"); string lastname = keyboard.nextline(); system.out.println("what supe...

php - Error Code: 10944642 Error Message: Error: Inbound SOAP Message - Session Token is missing -

i trying call siebel wsdl, $wsdl = '/home/netvibes/mysw/public/r2/img/isusertrusted.wsdl'; $client = new soapclient($wsdl, array( "trace"=>1, "exceptions"=>0)); $auth = array( 'usernametoken' => 'extapp', 'passwordtext' => 'extapp' ); $header = new soapheader('namespace', 'auth', $auth, false); $client->__setsoapheaders($header); $result = $client->__call('execute_service', array('appthai123zz@zzhotmail.swk') ); i dont know doing wrong, when get, error code: 10944642 error message: error: inbound soap message - session token missing may wrong header. can please help? can share actual message you're sending? error typical when send message missing session token tag. token sent siebel after initial login, prevents having log in each message - reducing au...

ios - UITesting How to get a number that's a part of the tabBar section? -

Image
sorry title, didn't know how word question. here's picture help: i want able number "5" next notifications tab variable , struggling so. "notifications" tab button xcuiapplication().tabbars.buttons["notifications"] each uitabbaritem has badgevalue tabbarcontroller?.tabbar.items?[3].badgevalue

python - pandas df.loc[z,x]=y how to improve speed? -

Image
i have identified 1 pandas command timeseries.loc[z, x] = y to responsible of time spent in iteration. , looking better approaches accelerate it. loop covers not 50k elements (and production goal ~250k or more), needs sad 20 seconds. here code (ignore top half, timing helper) def populatetimeseriestable(df, observable, timeseries): """ go through rows of df , put observable timeseries @ correct row (symbol), column (tsmean). """ print "len(df.index)=", len(df.index) # show number of rows global bf, t bf = time.time() # set 'before' t = dict([(i,0) in range(5)]) # fill category timing zeros def t(i): """ timing helper: add passed time category 'i'. set 'before' now. """ global bf, t t[i] = t[i] + (time.time()-bf) bf = time.time() in df.index: ...