too many values to unpack (expected 2) no Django

Estou com este trecho de código no Django, a intenção é inserir, se já existir o ds_user_id então ele atualiza o usuário com esse ds_user_id ao invés de criar um novo

ds_user_id = int(post_login['ds_user_id']) csrftoken = post_login['csrftoken'] cookies = json.dumps(str(post_login['cookies']))  defaults = {   'username': username,   'password': password,   'ds_user_id': ds_user_id,   'csrftoken': csrftoken,   'cookies': cookies,   'status': 0 }  try:   obj = User.objects.get(ds_user_id=ds_user_id)    for key, value in defaults.keys():     setattr(obj, key, value) except User.DoesNotExist:   new_values = {     'username': username,     'password': password,     'ds_user_id': ds_user_id,     'csrftoken': csrftoken,     'cookies': cookies,     'status': 0   }    new_values.update(defaults)    obj = User(**new_values) 

O insert funcionou porém, ao tentar logar novamente, recebo:

too many values to unpack (expected 2)

Eu não estou entendendo muito bem, mas eu acho que é esta linha que está buguizando meu código:

for key, value in defaults.keys(): 

When knowing an individual’s plaintext password history, how much information is expected to be gained with a new password? Do we know this?

The premise: Knowing a persons password history should provide information to help when guessing a new password of theirs.

At an extreme end, with a password history of wildcats, wildcats1, then wildcats2, I’d guess there is less than 1 bit of entropy in their next answer.

At the other extreme end, someone with randomly generated passwords would lose no information in their history. From an information-theoretic point of view, I imagine this is something we can estimate using the large amounts of password history data available in the world.

Somewhere in the middle, a history of “wildcats!Reddit”, “crazydogs!Facebook”, “locobirds!Stackexchange” would give me some good ideas for a Twitter password, and would greatly reduce the entropy of their hash. Of course, this would be related to the concept of password strength.

I’m not so well-read on security, but I assume my idea is not unique. Is there a name for this concept? Do we know any real-world values for the amount of information gained / entropy lost?

How to fix “expected call-signature to have a typedef” error

I have a switch case function inside my render JSX element that I am using in another const value based on the return values.

I tried looking for a solution to my issue online but none of the answers I found are helping my issue, even after trying them on my code.

            switch(transitionTypeValue) {                 //Different cases and their return values             }    }     const classes = xyz(carouselClass(transitionType)) //Sample of where I'm using my switch function 

The code runs fine on Typescript side but I get a linting error which says “typedef expected call-signature: ‘carouselClass’ to have a typedef”

I tried my best to give enough context, please let me know if more is required as this is my first time posting a question.

Retrofit fails to download binary file in an Android app – end result is a corrupted file that is larger than expected

I am trying to download PDF files using Retrofit 2 on an Android app written in Kotlin. The snippet below is basically my entire code. Based on my log output, it appears that the file downloads successfully and saves to the intended location.

However, the downloaded file is larger than expected, and is corrupt. I can open it in a PDF reader, but the PDF is blank. In the example below, I tried downloading If I download this file through a browser, the result is a PDF that is 13,264 bytes. Downloaded with this code however, it is 22,503 bytes, about 70% larger than expected. I am getting a similar result for other binary files like JPEGs. However, downloading a TXT actually works fine, even a large one. So it seems like the problem is isolated to binary files.

package com.ebelinski.RetrofitTestApp  import import android.content.Context import android.os.Build import import android.os.Bundle import android.util.Log import import import okhttp3.OkHttpClient import okhttp3.ResponseBody import org.jetbrains.anko.doAsync import retrofit2.Call import retrofit2.http.* import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import* import java.util.concurrent.Executors import java.util.concurrent.TimeUnit  interface FileService {      @Streaming     @GET     @Headers("Content-Type: application/pdf", "Accept: application/pdf")     fun fileFromUrl(@Url url: String,                     @Header("Authorization") tokenTypeWithAuthorization: String): Call<ResponseBody>  }  class MainActivity : AppCompatActivity() {      val TAG = "MainActivity"      val RETROFIT_CONNECT_TIMEOUT_SECONDS = 60     private val RETROFIT_READ_TIMEOUT_SECONDS = 60     private val RETROFIT_WRITE_TIMEOUT_SECONDS = 60      private val retrofit: Retrofit         get() {             val gson = GsonBuilder()                 .setDateFormat("yyyyMMdd")                 .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)                 .create()              val converterFactory = GsonConverterFactory.create(gson)              val okHttpClient = OkHttpClient.Builder()                 .connectTimeout(RETROFIT_CONNECT_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)                 .readTimeout(RETROFIT_READ_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)                 .writeTimeout(RETROFIT_WRITE_TIMEOUT_SECONDS.toLong(), TimeUnit.SECONDS)                 .addInterceptor { chain ->                     val userAgentValue = "doesn't matter"                     val originalRequest = chain.request().newBuilder().addHeader("User-Agent", userAgentValue).build()                      var response = chain.proceed(originalRequest)                     if (BuildConfig.DEBUG) {                         val bodyString = response.body()!!.string()                         Log.d(TAG, String.format("Sending request %s with headers %s ", originalRequest.url(), originalRequest.headers()))                         Log.d(TAG, String.format("Got response HTTP %s %s \n\n with body %s \n\n with headers %s ", response.code(), response.message(), bodyString, response.headers()))                         response = response.newBuilder().body(ResponseBody.create(response.body()!!.contentType(), bodyString)).build()                     }                      response                 }                 .build()              return Retrofit.Builder()                 .callbackExecutor(Executors.newCachedThreadPool())                 .baseUrl("")                 .addConverterFactory(converterFactory)                 .client(okHttpClient)                 .build()         }      private val fileService: FileService = retrofit.create(      override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)          doAsync { downloadFile() }     }      fun downloadFile() {         val uri = ""         val auth = "doesn't matter"          val response = fileService.fileFromUrl(             uri,             auth         ).execute()          if (!response.isSuccessful) {             Log.e(TAG, "response was not successful: " +                     response.code() + " -- " + response.message())             throw Throwable(response.message())         }          Log.d(TAG, "Server has file for $  {uri}")         saveFileFromResponseBody(response.body()!!)     }        // Returns the name of what the file should be, whether or not it exists locally     private fun getFileName(): String? {         return "dummy.pdf"     }      fun saveFileFromResponseBody(body: ResponseBody): Boolean {         val fileName = getFileName()         val localFullFilePath = File(getFileFullDirectoryPath(), fileName)         var inputStream: InputStream? = null         var outputStream: OutputStream? = null         Log.d(TAG, "Attempting to download $  fileName")          try {             val fileReader = ByteArray(4096)             val fileSize = body.contentLength()             var fileSizeDownloaded: Long = 0              inputStream = body.byteStream()             outputStream = FileOutputStream(localFullFilePath)              while (true) {                 val read =                 if (read == -1) break                  outputStream.write(fileReader, 0, read)                 fileSizeDownloaded += read.toLong()                  Log.d(TAG, "$  fileName download progress: $  fileSizeDownloaded of $  fileSize")             }              outputStream.flush()             Log.d(TAG, "$  fileName downloaded successfully")             return true         } catch (e: IOException) {             Log.d(TAG, "$  fileName downloaded attempt failed")             return false         } finally {             inputStream?.close()             outputStream?.close()         }     }      fun getFileFullDirectoryPath(): String {         val directory = getDir("test_dir", Context.MODE_PRIVATE)         return directory.absolutePath     } } 

If it helps, here’s my build.gradle file:

apply plugin: ''  apply plugin: 'kotlin-android'  apply plugin: 'kotlin-android-extensions'  android {     compileSdkVersion 28     defaultConfig {         applicationId "com.ebelinski.RetrofitTestApp"         minSdkVersion 21         targetSdkVersion 28         versionCode 1         versionName "1.0"         testInstrumentationRunner ""     }     buildTypes {         release {             minifyEnabled false             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), ''         }     } }  dependencies {     implementation fileTree(dir: 'libs', include: ['*.jar'])     implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$  kotlin_version"     implementation ''     implementation ''     implementation 'com.squareup.retrofit2:converter-gson:2.5.0'     implementation 'com.squareup.retrofit2:retrofit:2.5.0'     implementation 'com.squareup.okhttp3:okhttp:3.12.0'     implementation "org.jetbrains.anko:anko-commons:0.10.1"     testImplementation 'junit:junit:4.12'     androidTestImplementation ''     androidTestImplementation '' } 

PowerShell – Return doesn’t behave as expected

I’m using PowerShell v5.1. I have a question about “Return”. Shouldn’t “Return” stop script execution?

Get-CimInstance Win32_OperatingSystem | ForEach-Object {     "Exiting"     Return } "It doesn't"  ForEach ($  number in 1..2){     "Exiting"     Return } "It doesn't" 

Result is: Exiting => It doesn’t => Exiting

As you can see “Return” behaves differently inside “ForEach-Object” loop then inside “ForEach” loop. What am I missing? Thank you 🙂

Alerts for A View not working as expected

We have a library that includes a column with 3 choices. We have made a view that display all items where choice = Option2. We subsequently set alerts on new items added to that view and for testing alerts for the base library. Users will receive alerts set for all new docs and will not receive alerts for docs that fit a view.

I have verified that all web servers and app servers can send email. I checked logs and have verified that immediate alerts jobs run and are sent and received, just not for the alerts based on a view.

What else can I check? Is this a bug?

Bash if clause not working as expected

#!/bin/bash python3 -c "import numpy" if [ $  ? ]; then     echo Numpy needs to be installed     sudo apt-get python3-numpy fi echo Everything is properly installed 

This is what I’m trying to run.

Supposedly, it checks if numpy is already installed and if not, install it. However, it installs everytime, even though I already have it.

When I change import numpy to import asdfas it still installs numpy, so the if is not doing anything at all!

I’m sorry if this is already answered, but my google search didn’t find this specific error

Expected values of packing distance between vectors with Bernoulli trials?

Pick set $ \mathcal T$ of $ 2^k$ vectors in $ \{-1,+1\}^n$ with Bernoulli trials.

What are exact expected values or at least tight bounds of $ $ \min_{\substack {u,v\in\mathcal T\u\neq v}}\|u-v\|_2^2$ $ $ $ \min_{\substack {u,v\in\mathcal T\u\neq v}}\|u-v\|_1$ $ and their distributions?

Docker pull then start for running container – what is the expected behavior?

Let’s say I have a running Docker container X that is based on image foo.

If I pull a new version of foo, then stop and delete X, and then docker run foo – will it have the new version of the image?

Said differently – do I need to stop X before I can pull the new version of foo and then start it?

The context is Docker-EE on Windows Server 2016.