天道酬勤,学无止境

问答

Decrypting in pgpy fails with "ValueError: Expected: ASCII-armored PGP data"

I have an OpenPGP encrypted file and its private key in a text file and know its passphrase. I tried this below code: import pgpy emsg = pgpy.PGPMessage.from_file('PGPEcrypted.txt') key,_ = pgpy.PGPKey.from_file('PrivateKey.txt') with key.unlock('passcode!'): print (key.decrypt(emsg).message) But while trying to execute I am getting following error: Traceback (most recent call last): File "D:\Project\PGP\pgp_test.py", line 4, in <module> key,_ = pgpy.PGPKey.from_file('SyngentaPrivateKey.txt') File "D:\Anaconda\lib\site-packages\pgpy\types.py", line 191, in from_file po = obj.parse(data) File

2022-01-25 05:39:53   python   encryption   gpgpu   pgp   openpgp

Error after adding Django channels to installed_apps in settings file

I am just trying out django channels so I created a virtual environment and installed django, drf and channels. It threw error asking for visual c++ build tools which got resolved after installing it. Then I created a channels project and an app. Then just for testing I added a sample model as below and registered it with the admin. It compiled well and also I was able to see the model in the admin page. My Model Calss from django.db import models # Create your models here. class College(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=150) objects =

2022-01-25 05:39:49   django   django-channels

Networkx: how get attribute color from the graph

I have graph and I need to get color of nodes. I try to use color = nx.get_node_attributes(G, 'color') But it returns empty dictionary. What I do wrong? Graph was generated with G = nx.erdos_renyi_graph(100, 0.05) pos = nx.spring_layout(G) nx.draw_networkx_nodes(G, pos, G.nodes(), node_size=20, node_color='b') nx.draw_networkx_edges(G,pos, alpha=0.3) plt.show()

2022-01-25 05:39:45   python   networkx

failed to open stream: No such file

when i update my project from codeigniter 2 to codeigniter 3.1.0 am getting error like this "Warning: include(C:\wamp64\www\hosteliam\application\views\errors\html\error_php.php): failed to open stream: No such file or directory in C:\wamp64\www\hosteliam\system\core\Exceptions.php on line 269"`. this is my line on exception ob_start(); include($templates_path.$template.'.php'); $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; where line 269 is include($templates_path.$template.'.php');

2022-01-25 05:39:38   php   codeigniter

How to get new input to generator in Python without create a new generator

I try to write code that gets a list and generates all of this transformations by using yield statement. The problem is when I want to get new input to generator by using send function, I continue to get the old input. def permute(items): permutations = [x for x in itertools.permutations(items)] permutations.sort() for n in permutations: yield (n) g = permute(['b','a','c']) print(next(g)) #('a', 'b', 'c') print(next(g)) #('a', 'c', 'b') g.send(['e','q','c']) print(next(g)) #('b', 'c', 'a') need to be ('c', 'e', 'q') How can I empty the permutation list and repeat to sorting permutations list

2022-01-25 05:39:30   python   yield

How to convert `c(a,b)` to parameter of `table(a,b)`?

I need to write function vec_to_para,when I run vec_to_para(c('vs','gear'),mtcars),should output result of with(mtcars,table(vs,gear)). I asked a similar quesiton yesterday,then I tried paste() #expected result > with(mtcars,table(vs,gear)) gear vs 3 4 5 0 12 2 4 1 3 10 1 #my function,where is the problem? >vec_to_para<-function(vec,df){ with(df,tables(paste(vec,collapse=','))) } #run to test function >vec_to_para(c('vs','gear'),mtcars) vs,gear 1 Where is the problem of vec_to_para function?

2022-01-25 05:39:25   r

Checking on empty gems cache fails using Serverspec for Docker image build testing

I'm currently having an issue with testing Docker image builds by means of Serverspec. In a nutshell, what I want to do is ensuring that during the image build the Ruby gems build cache gets cleared explicitly, e.g. by issuing rm -rf /usr/lib/ruby/gems/*/cache/*.gem in the Dockerfile. The Dockerfile skeleton I'm working with looks like this: # Dockerfile FROM alpine:3.7 RUN apk add --no-cache \ dumb-init \ ruby \ && apk add --no-cache --virtual .build-deps \ build-base \ ruby-dev RUN gem install --no-rdoc --no-ri json \ && gem install --no-rdoc --no-ri oj RUN apk del .build-deps \ && rm -rf

2022-01-25 05:39:17   ruby   docker   rspec   rubygems   serverspec

Turning a list of rows into columns

foo = ['123','123','123] I am attempting to turn foo into: revisedfoo = ['111', '222', '333'] This in effect is turning the "rows" into "columns": 111 222 333 I have attempted something along these lines: for j in range(len(foo)): for i in range(len(foo)): revisedfoo.append(foo[i][j]) But it leaves me with: revisedfoo = ['1','1','1','2','2','2','3','3','3'] Any help would be appreciated!

2022-01-25 05:39:08   python   python-3.x

How to pass string data from Master-Detail Page in Xamarin Forms

I am trying to make a Master-Detail Navigation using help of this github example. The relevant code sample from my project is - MasterPageItem.cs namespace Demo.MenuItems { public class MasterPageItem { public string Title { get; set; } public string IconSource { get; set; } public Type TargetType { get; set; } } } MainPage.Xaml.cs public partial class MainPage : MasterDetailPage { public MainPage() { InitializeComponent(); masterPage.ListView.ItemSelected += OnItemSelected; if (Device.RuntimePlatform == Device.UWP) { MasterBehavior = MasterBehavior.Popover; } Detail = new NavigationPage(new

2022-01-25 05:39:00   c#   xaml   xamarin   xamarin.forms   master-detail

org.apache.hadoop.security.AccessControlException: Permission denied: user=test-user, access=EXECUTE, inode="system":hadoop:test-user:rwx------

Previously test-user used to reside on an edge server to which connectivity was lost. Hence we reconstructed the edge server and have been trying to get it up and running but I keep getting the below error. Job initialization failed: org.apache.hadoop.security.AccessControlException: org.apache.hadoop.security.AccessControlException: Permission denied: user=test-user, access=EXECUTE, inode="system":hadoop:test-user:rwx------ at sun.reflect.GeneratedConstructorAccessor20.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl

2022-01-25 05:38:56   hadoop