小编Dak*_*kar的帖子

Mac OS X和多个Java版本

如何在MacOS上安装额外的Java?我安装了jdk8,工作正常.但现在我需要一个jdk7安装用于开发目的.当尝试通过DMG文件安装旧版本时,我收到警告,已经安装了较新版本的Java并且安装程序退出.

/usr/libexec/java_home -verbose
Matching Java Virtual Machines (1):
    1.8.0_20, x86_64:   "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home

   /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
Run Code Online (Sandbox Code Playgroud)

除了这个之外,如何安装jdk7?

谢谢
Dakky

java macos multiple-versions homebrew-cask jenv

294
推荐指数
14
解决办法
20万
查看次数

Ruby:模块,需求和包含

我正在尝试使用Ruby模块(mixins).

我有test.rb:

#!/usr/bin/env ruby
require_relative 'lib/mymodule'

class MyApp
  include MyModule
  self.hallo
end
Run Code Online (Sandbox Code Playgroud)

和lib/mymodule.rb:

module MyModule
  def hallo
    puts "hallo"
  end
end
Run Code Online (Sandbox Code Playgroud)

非常简单的设置.但它不起作用:(:

ruby test.rb
test.rb:8:in `<class:MyApp>': undefined method `hallo' for MyApp:Class (NoMethodError)
        from test.rb:6:in `<main>'
Run Code Online (Sandbox Code Playgroud)

我的错误在哪里?

ruby module mixins

43
推荐指数
3
解决办法
6万
查看次数

Pytest:设置testclient和DB

我正在尝试学习测试我的烧瓶应用程序.为了做到这一点,我使用pytest和sqlalchemy.

我想测试一个模板,其传递路由一些SQL内容.所以在我看来,我需要一个testClient来测试路由本身和一个数据库工具来管理路由中包含的数据库内容.

这是我的装备:

import pytest
from config import TestingConfig
from application import create_app, db


# ###########################
# ## functional tests
# ###########################


@pytest.fixture(scope='module')
def test_client():
    app = create_app(TestingConfig)

    # Flask provides a way to test your application by exposing the Werkzeug 
    # test Client and handling the context locals for you.
    testing_client = app.test_client()

    with app.app_context():

        db.create_all()

        yield testing_client  # this is where the testing happens!

        db.drop_all()
Run Code Online (Sandbox Code Playgroud)

这是我的基本测试:

def test_home_page(test_client):
    """
    GIVEN a Flask application
    WHEN the '/' page is …
Run Code Online (Sandbox Code Playgroud)

python sqlalchemy pytest flask python-3.x

11
推荐指数
2
解决办法
2404
查看次数

Ruby:Logger和Daemons

我正在使用ruby 1.9.2p180(2011-02-18修订版30909)

为了进行日志记录,我使用了日志记录宝石.我的程序有两个块,用作守护进程.

但是从这些块进行日志记录会导致错误,并且没有任何内容写入日志文件:

log shifting failed. closed stream
log writing failed. closed stream
Run Code Online (Sandbox Code Playgroud)

以下是代码中发生的情况:

log = Logger.new(logbase + 'logfile.log', 'monthly')
log.level = Logger::INFO

proc = Daemons.call(options) do
  # [...]
  log.info "Any Logmessage"
  # [...]
end
Run Code Online (Sandbox Code Playgroud)

任何想法,哪里错了?

ruby logging daemons

7
推荐指数
1
解决办法
5262
查看次数

如何用augeas改变属性值,这些位置改变了XML?

我有以下问题:

我的XML(简化):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <properties>
    <property name="username">USERNAME</property>
    <property name="anything">blabla</property>
  </properties>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我需要用augeas替换Username值.它适用于:

augtool> set /files/test.xml/configuration/properties/property[1]/#text NEWUSER
Run Code Online (Sandbox Code Playgroud)

但问题是:用户名输入并不总是在第一位.在augeas中有没有办法用"匹配"或某种正则表达式来寻找位置?

augtool> match /files/test.xml/configuration/properties/*/#attribute/name  username
Run Code Online (Sandbox Code Playgroud)

工作得很好

/files/test.xml/configuration/properties/property[1]/#attribute/name
Run Code Online (Sandbox Code Playgroud)

但我不知道在设置值时如何使用此信息.

xml puppet augeas

3
推荐指数
1
解决办法
3526
查看次数

特定的python如果构造

我正在尝试将Python实用程序转换为Ruby.问题是不太了解python.

该实用程序的一个片段包括以下if条件:

if bits&0x10==0x10: 
Run Code Online (Sandbox Code Playgroud)

那是什么意思?bits是一个变量.它是某种"缩短""&&",意味着如果位非零并且值为0x10?谢谢!

python conditional-statements

0
推荐指数
2
解决办法
184
查看次数

Ansible, with_subelements and skip_missing does not work

I have the following problem:
A host_var defining my nginx sites (excerpt):

nginx_sites:
- server:
    name: site1
    location1:
      config:
        name: "/"
        [...]
- server:
    name: site2
    location1:
      config:
        name: "/"
        [...]
    location2:
      config:
        name: "/secretspace"
        [...]
      htaccess:
        username:
          password: somepassword
Run Code Online (Sandbox Code Playgroud)

In this example I have 2 sites. The second one has two locations where the second one has a subelement named "htaccess". This is what I want to use in order to create an corresponding htaccess file.

I tried this …

ansible ansible-playbook

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