小编ins*_*-IT的帖子

什么是'NoneType'对象?

我在运行python脚本时收到此错误:

TypeError: cannot concatenate 'str' and 'NoneType' objects
Run Code Online (Sandbox Code Playgroud)

我很确定'str'意味着字符串,但我不知道'NoneType'对象是什么.我的脚本在第二行开始了,我知道第一行是有效的,因为来自该行的命令在我的asa中,正如我所期望的那样.起初我以为可能是因为我在send_command中使用变量和用户输入.

'CAPS'中的所有内容都是变量,'小写'中的所有内容都是从'parser.add_option'选项输入的.

我正在使用pexpect和optparse

send_command(child, SNMPGROUPCMD + group + V3PRIVCMD)
send_command(child, SNMPSRVUSRCMD + snmpuser + group + V3AUTHCMD + snmphmac + snmpauth + PRIVCMD + snmpencrypt + snmppriv)
Run Code Online (Sandbox Code Playgroud)

python null nonetype

67
推荐指数
5
解决办法
24万
查看次数

Rake正在中止,因为未定义的方法`inet'

我应该在哪里以及如何定义inet?它是一种有效的postgreSQL数据类型.

http://www.postgresql.org/docs/8.4/static/datatype-net-types.html

rake db:migrate
==  CreateSysHosts: migrating =================================================
-- create_table(:sys_hosts)
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `inet' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0x00000005e3e068>/opt/csdashboard/db/migrate/20140628123004_create_sys_hosts.rb:4:in `block in change'
Run Code Online (Sandbox Code Playgroud)

迁移文件:

class CreateSysHosts < ActiveRecord::Migration
  def change
    create_table :sys_hosts do |t|
      t.inet :address
      t.string :name
      t.string :os_name
      t.string :os_flavor
      t.int :user_id
      t.string :info
      t.string :comments

      t.timestamps
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails

5
推荐指数
1
解决办法
3001
查看次数

类型错误:强制转换为 Unicode:需要字符串或缓冲区,已找到文件

我收到缓冲区错误,但我在第 123 行的“with open()”块中有一个行缓冲区。这是缓冲区的正确位置吗?我是否应该在连接类中也有一些东西/相反,或者可能是解析器参数。

我尝试使用带有“--host_file”参数的地址或主机名文件在多个 ASA 上运行 SNMP 命令。使用“--host”参数就可以了。

提供的任何帮助将不胜感激。

Traceback (most recent call last):
  File "asaos-snmpv3-tool.py", line 145, in <module>
    main()
  File "asaos-snmpv3-tool.py", line 124, in main
    with open(hosts, mode='r', buffering=-1):
TypeError: coercing to Unicode: need string or buffer, file found

import pexpect
import argparse

PROMPT = ['# ', '>>> ', '>', '\$ ']
SNMPGROUPCMD = ' snmp-server group '
V3PRIVCMD = ' v3 priv '
SNMPSRVUSRCMD = ' snmp-server user '
V3AUTHCMD = ' v3 auth '
PRIVCMD …
Run Code Online (Sandbox Code Playgroud)

python unicode

4
推荐指数
1
解决办法
2万
查看次数

你如何使用python的os.system()"回显"引号?

我正在尝试使用标准的bash脚本编写一个monit配置文件,如果是python的话os.system(),这个字符串是我想模仿的.

echo -e "\t" start program = \""/etc/init.d/snortd00 start\"" >> /etc/monit.d/ips_svcs.monit
Run Code Online (Sandbox Code Playgroud)

这是我尝试使用的os.system().它们都产生相同的结果.这些都没有写引号/etc/init.d/snortd00 start

   os.system('echo -e \"\t\" start program = \""/etc/init.d/snortd00 start\"" >> /etc/monit.d/ips_svcs.monit')

   os.system('echo -e \"\t\" start program = \"\"/etc/init.d/snortd00 start\"\" >> /etc/monit.d/ips_svcs.monit')

   os.system('echo -e \"\t\" start program = "/etc/init.d/snortd00 start" >> /etc/monit.d/ips_svcs.monit')

   os.system('echo -e \"\t\" start program = "\"/etc/init.d/snortd00 start\"" >> /etc/monit.d/ips_svcs.monit')
Run Code Online (Sandbox Code Playgroud)

这是使用所有四个os.system()语句编写的内容.start program = /etc/init.d/snortd00 start

我正在寻找这个 start program = "/etc/init.d/snortd00 start"

python bash python-2.7

3
推荐指数
2
解决办法
6524
查看次数

错误的参数数量(1比2),但我相信我已经过了两个

wrong number of arguments (1 for 2)即使我传递了两个论点,我也会得到一个.

无论如何我试图..

这是应用程序跟踪.

app/controllers/ips_dashboard_controller.rb:6:in `initialize'
app/controllers/ips_dashboard_controller.rb:82:in `new'
app/controllers/ips_dashboard_controller.rb:82:in `block (2 levels) in ips_dashboard'
app/controllers/ips_dashboard_controller.rb:81:in `each'
app/controllers/ips_dashboard_controller.rb:81:in `block in ips_dashboard'
app/controllers/ips_dashboard_controller.rb:74:in `each'
app/controllers/ips_dashboard_controller.rb:74:in `ips_dashboard'
Run Code Online (Sandbox Code Playgroud)

这里我在db中查找ip地址并将数组传递IP_data给Seer :: visualize中使用的类.

# Begin lookups for tgt addresses
target_ip_data = Array.new
@tgt_ip_array = Array.new
@events.each do |ip_event|
  def get_target_ip(sid,cid)
    IpsIpHdr.where('sid =? and cid =?', sid, cid).first.ip_dst
  end
  tgt_ip = get_target_ip(ip_event.sid, ip_event.cid).to_s(16).rjust(8,'0').scan(/.{2}/).map(&:hex).join('.')
  target_ip_data.push(tgt_ip)
  @tgt_ip_hash = Hash[target_ip_data.group_by {|x| x}.map {|k,v| [k,v.count]}]
  @tgt_ip_hash.each do |t|
    @tgt_ip_array.push(IP_data.new(:ip => t[0],:count => t[1])) …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails

0
推荐指数
1
解决办法
55
查看次数

标签 统计

python ×3

ruby-on-rails ×2

bash ×1

nonetype ×1

null ×1

postgresql ×1

python-2.7 ×1

unicode ×1