2018年12月31日月曜日

バッテリー充電器

乗る回数も少ないこともあるけれど所詮バッテリーには寿命がある。

HONDA CB223Sに付いていたバッテリーはGS YUASAのYTZ7S、一度はHONDA DREAM店で交換をしてもらったこともあったけれど今回は・・・。

なんとなくサイドカバーを外してみると10mmのレンチとプラスドライバーだけで簡単にバッテリーを取り外す事が出来ることに気がつきまずは自分で充電してみることにした。

さっそくバッテリー充電器にを調べてみると意外に種類があり候補としては


  • Meltec
  • セルスター
  • BAL(大橋産業株式会社)

各社の製品の中から上記バッテリーに対応していることが当然でなおかつ対応容量をどこまで求めるか思案、結局バイクのみに使う事を前提してサイズや操作性、コストから競るスターのDSR-300をチョイス。

実際、充電してみたところ説明書に記載されていた目安で充電しても充電済にならずたぶんバッテリー自体弱っていてあまり充電されてなさそう。
この充電器は説明によるとバッテリーの状態によって最適な充電をしてくれるらしいのだけれど・・・さらにブーストモードなる高い電圧で充電をおこないバッテリーを救済することもできること期待したのだけれどよほど状態が悪いのかそれとも救済されたからこそ多少は充電されたのかもしれない。

またしばらく乗ってバッテリーが上がってしまった時には今度はバッテリーを交換しよう。

バッテリーも値段がピンキリでまぁ冒険をするつもりがないので今と同じか古河電池株式会社のFTZ7Sかな。


macOS パッケージ管理システム(Homebrew)インストール

あまり色々とアプリをインストールしたくないのだけれどpythonを勉強するためにpythonをインストールすることに、macOS(10.14.2 Mojave)には標準で2.7.10がインストールされているけれどできればpython3を使いたい。

色々調べてみるとパッケージ管理システム(yum、apt-getの同類)を使用してインストールする例が多く、MacPortsと悩んでこちらのサイトを参考にHomebrewをインストール。

参考サイトでは手順でJAVAとCommand Line ToolsをインストールをしているけれどとりあえずHmoebrewの公式サイトのインストールコマンドをコピーしてターミナルから実行


【実行ログ】
 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
==> The following existing directories will have their owner set to [ユーザ名hogehoge]:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
==> The following existing directories will have their group set to admin:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
==> The following new directories will be created:
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Homebrew
/usr/local/Frameworks
==> The Xcode Command Line Tools will be installed.

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1
Password:

パスワードを入力

==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1
==> /usr/bin/sudo /usr/sbin/chown [ユーザ名hogehoge] /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1
==> /usr/bin/sudo /bin/mkdir -p /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown [ユーザ名hogehoge] /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/mkdir -p /Users/[ユーザ名hogehoge]/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/[ユーザ名hogehoge]/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown [ユーザ名hogehoge] /Users/[ユーザ名hogehoge]/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/mkdir -p /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown [ユーザ名hogehoge] /Library/Caches/Homebrew
==> Searching online for the Command Line Tools
==> /usr/bin/sudo /usr/bin/touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> Installing Command Line Tools (macOS Mojave version 10.14) for Xcode-10.1
==> /usr/bin/sudo /usr/sbin/softwareupdate -i Command¥ Line¥ Tools¥ (macOS¥ Mojave¥ version¥ 10.14)¥ for¥ Xcode-10.1
Software Update Tool


Downloading Command Line Tools (macOS Mojave version 10.14) for Xcode
Downloaded Command Line Tools (macOS Mojave version 10.14) for Xcode
Installing Command Line Tools (macOS Mojave version 10.14) for Xcode
Done with Command Line Tools (macOS Mojave version 10.14) for Xcode
Done.
==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
==> Downloading and installing Homebrew...
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 116175 (delta 8), reused 10 (delta 5), pack-reused 116143
Receiving objects: 100% (116175/116175), 27.36 MiB | 4.23 MiB/s, done.
Resolving deltas: 100% (84822/84822), done.
From https://github.com/Homebrew/brew
 * [new branch]          master     -> origin/master
 * [new tag]             0.1        -> 0.1
 * [new tag]             0.2        -> 0.2
 * [new tag]             0.3        -> 0.3
 * [new tag]             0.4        -> 0.4
 * [new tag]             0.5        -> 0.5
 * [new tag]             0.6        -> 0.6
 * [new tag]             0.7        -> 0.7
 * [new tag]             0.7.1      -> 0.7.1
 * [new tag]             0.8        -> 0.8
 * [new tag]             0.8.1      -> 0.8.1
 * [new tag]             0.9        -> 0.9
 * [new tag]             0.9.1      -> 0.9.1
 * [new tag]             0.9.2      -> 0.9.2
 * [new tag]             0.9.3      -> 0.9.3
 * [new tag]             0.9.4      -> 0.9.4
 * [new tag]             0.9.5      -> 0.9.5
 * [new tag]             0.9.8      -> 0.9.8
 * [new tag]             0.9.9      -> 0.9.9
 * [new tag]             1.0.0      -> 1.0.0
 * [new tag]             1.0.1      -> 1.0.1
 * [new tag]             1.0.2      -> 1.0.2
 * [new tag]             1.0.3      -> 1.0.3
 * [new tag]             1.0.4      -> 1.0.4
 * [new tag]             1.0.5      -> 1.0.5
 * [new tag]             1.0.6      -> 1.0.6
 * [new tag]             1.0.7      -> 1.0.7
 * [new tag]             1.0.8      -> 1.0.8
 * [new tag]             1.0.9      -> 1.0.9
 * [new tag]             1.1.0      -> 1.1.0
 * [new tag]             1.1.1      -> 1.1.1
 * [new tag]             1.1.10     -> 1.1.10
 * [new tag]             1.1.11     -> 1.1.11
 * [new tag]             1.1.12     -> 1.1.12
 * [new tag]             1.1.13     -> 1.1.13
 * [new tag]             1.1.2      -> 1.1.2
 * [new tag]             1.1.3      -> 1.1.3
 * [new tag]             1.1.4      -> 1.1.4
 * [new tag]             1.1.5      -> 1.1.5
 * [new tag]             1.1.6      -> 1.1.6
 * [new tag]             1.1.7      -> 1.1.7
 * [new tag]             1.1.8      -> 1.1.8
 * [new tag]             1.1.9      -> 1.1.9
 * [new tag]             1.2.0      -> 1.2.0
 * [new tag]             1.2.1      -> 1.2.1
 * [new tag]             1.2.2      -> 1.2.2
 * [new tag]             1.2.3      -> 1.2.3
 * [new tag]             1.2.4      -> 1.2.4
 * [new tag]             1.2.5      -> 1.2.5
 * [new tag]             1.2.6      -> 1.2.6
 * [new tag]             1.3.0      -> 1.3.0
 * [new tag]             1.3.1      -> 1.3.1
 * [new tag]             1.3.2      -> 1.3.2
 * [new tag]             1.3.3      -> 1.3.3
 * [new tag]             1.3.4      -> 1.3.4
 * [new tag]             1.3.5      -> 1.3.5
 * [new tag]             1.3.6      -> 1.3.6
 * [new tag]             1.3.7      -> 1.3.7
 * [new tag]             1.3.8      -> 1.3.8
 * [new tag]             1.3.9      -> 1.3.9
 * [new tag]             1.4.0      -> 1.4.0
 * [new tag]             1.4.1      -> 1.4.1
 * [new tag]             1.4.2      -> 1.4.2
 * [new tag]             1.4.3      -> 1.4.3
 * [new tag]             1.5.0      -> 1.5.0
 * [new tag]             1.5.1      -> 1.5.1
 * [new tag]             1.5.10     -> 1.5.10
 * [new tag]             1.5.11     -> 1.5.11
 * [new tag]             1.5.12     -> 1.5.12
 * [new tag]             1.5.13     -> 1.5.13
 * [new tag]             1.5.14     -> 1.5.14
 * [new tag]             1.5.2      -> 1.5.2
 * [new tag]             1.5.3      -> 1.5.3
 * [new tag]             1.5.4      -> 1.5.4
 * [new tag]             1.5.5      -> 1.5.5
 * [new tag]             1.5.6      -> 1.5.6
 * [new tag]             1.5.7      -> 1.5.7
 * [new tag]             1.5.8      -> 1.5.8
 * [new tag]             1.5.9      -> 1.5.9
 * [new tag]             1.6.0      -> 1.6.0
 * [new tag]             1.6.1      -> 1.6.1
 * [new tag]             1.6.10     -> 1.6.10
 * [new tag]             1.6.11     -> 1.6.11
 * [new tag]             1.6.12     -> 1.6.12
 * [new tag]             1.6.13     -> 1.6.13
 * [new tag]             1.6.14     -> 1.6.14
 * [new tag]             1.6.15     -> 1.6.15
 * [new tag]             1.6.16     -> 1.6.16
 * [new tag]             1.6.17     -> 1.6.17
 * [new tag]             1.6.2      -> 1.6.2
 * [new tag]             1.6.3      -> 1.6.3
 * [new tag]             1.6.4      -> 1.6.4
 * [new tag]             1.6.5      -> 1.6.5
 * [new tag]             1.6.6      -> 1.6.6
 * [new tag]             1.6.7      -> 1.6.7
 * [new tag]             1.6.8      -> 1.6.8
 * [new tag]             1.6.9      -> 1.6.9
 * [new tag]             1.7.0      -> 1.7.0
 * [new tag]             1.7.1      -> 1.7.1
 * [new tag]             1.7.2      -> 1.7.2
 * [new tag]             1.7.3      -> 1.7.3
 * [new tag]             1.7.4      -> 1.7.4
 * [new tag]             1.7.5      -> 1.7.5
 * [new tag]             1.7.6      -> 1.7.6
 * [new tag]             1.7.7      -> 1.7.7
 * [new tag]             1.8.0      -> 1.8.0
 * [new tag]             1.8.1      -> 1.8.1
 * [new tag]             1.8.2      -> 1.8.2
 * [new tag]             1.8.3      -> 1.8.3
 * [new tag]             1.8.4      -> 1.8.4
 * [new tag]             1.8.5      -> 1.8.5
 * [new tag]             1.8.6      -> 1.8.6
HEAD is now at 7246ed368 Merge pull request #5457 from MikeMcQuaid/remove-travis-ci
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 4891, done.
remote: Counting objects: 100% (4891/4891), done.
remote: Compressing objects: 100% (4695/4695), done.
remote: Total 4891 (delta 48), reused 304 (delta 4), pack-reused 0
Receiving objects: 100% (4891/4891), 4.02 MiB | 2.66 MiB/s, done.
Resolving deltas: 100% (48/48), done.
Tapped 2 commands and 4675 formulae (4,933 files, 12.5MB).
==> Migrating /Library/Caches/Homebrew to /Users/[ユーザ名hogehoge]/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Already up-to-date.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Next steps:
- Run `brew help` to get started
- Further documentation: 
    https://docs.brew.sh

なんか、インストールは成功したっぽい

念のため参考サイトに従い以下のコマンドを実行してみると問題なさそう

>brew doctor
Your system is ready to brew.

次はpython3をインストールしよう

2018年12月15日土曜日

(docstring)書き方備忘録


とりあえず自分用に書き方を整理

コメント


def  fnc_hoge(args1, args2 = 1, args3 ):
      '''
    関数の説明

     Parameters
    --------------
    args1    :    str
        説明
    args2    :    int, default 1
        説明
    args3    : array-like ※配列であるケース
    args3    : list of int  ※配列に格納している型記載するケース

    Attributes ※Classの場合
    ----------
    attr1    : dict
        説明

    See Also ※関連して参照してほしいもの
    --------
    関連説明

    Notes
    -----
    特記事項

    Raises ※エラーが起きる条件
    ------
    DatabaseError
    データベース関連エラー


    Returns
    -------
    ret1    : int
        説明
 
    return ret1

一行の長さ


  • 一行は79文字、複数行に継続させる場合はバックスラッシュ(¥)
  • コメントなど制約の少ないコメントブロックは72行

二項演算子改行位置


  • 二項演算子の前で改行
int_var = (var1
                + var2
                + var3          

ソースファイルのエンコーディング

UTF-8
UTF-8の時はエンコーディング宣言をしない

import文


  • 行を分ける
  • fromで同一モジュール内のクラス等をimportする時は一行
  • 標準ライブラリ、サードパーティーライブラリ、個人独自ライブラリ順にグループ毎宣言しグループ毎に1行空ける
  • 絶対importを推奨(例 import hogepkg.hogelib)
  • ワイルドカードを使用したimportはしない

モジュールレベルの二重アンダースコア変数


  • docstringとimport文間に宣言する
  • import __futture__がある場合はその前

インラインコメント


  • 文と#の間には2つ以上のスペース入れる(自分の場合は4つ)
  • #とコメント文の間には1つスペースを入れる

命名規則


  • 外部から使用させたくない変数の場合は頭に"_"を付ける※実際に使用できない訳ではない
  • 外部から使用させたくない変数の場合は頭に"__"を付ける※絶対使用できない訳ではない
  • モジュールとパッケージは小文字、"_"は使用しない
  • クラス名は単語の頭文字を大文字にする(CapWords方式)
  • 関数名、変数名は小文字と単語を"_"でつなげる
  • メソッドとインスタンス変数は小文字と単語を"_"でつなげる
  • 定数は大文字と単語は"_"でつなげる

プログラミングでの推奨


  • ブール型の値とTrue、Falseを比較する時に "=="は使用しない(例 if var:)

アノテーション


def 関数名(引数:[型]) -> 戻り[値の型]:


help(関数名)で引数や戻り値の型について確認出来るようになる

参考










   

2018年12月5日水曜日

(PyInstaller)AttributeError: 'str' object has no attribute 'items'

勉強がてらにTkinter を使ったGUIツールを作成したので他のPCでも実行できるようにPyInstallerを使用して実行形式(exeファイル)を作成してみることに。

PyInstallerをインストール後、早速作成を試みたところ以下のエラーが発生

「AttributeError: 'str' object has no attribute 'items'」

backtraceを見てもエラー原因が分からず検索してみるとsetuptoolsのバージョンを上げると解消する事がありそうなことが判明

(現在の環境)

  • Windows7(64bit)
  • Python3.6.1
  • setuptools28.8.0


setuptoolsはPython3.6.1に同梱されていたものだけどPythonPackageIndexにあった最新の40.6.2(2018/11/29時点)にアップグレードしたところエラーが解消され無事実行ファイルが作成

今回は実行に必要なファイルを全てexeに包含したため95MByteにもなった・・・まぁ最近のPCならどってことないのかな。

2018年12月4日火曜日

RECYCLEBINの無効化でORA-02096

使用していないrecyclebinがOracleのバグのトリガーになっている事が判明し無効化することに。

recyclebinはOracleの起動も不要で即時反映できる認識だったためさっそく

ALTER SYSTEM SET RECYCLEBIN = OFF;

を実行してみると以下のエラーが発生

ORA-02096: 指定した初期化パラメータはこのオプションでは修正できません。

Oracle10gの時にも同じ様にしたはずだったけれど・・・・。

alter systemのドキュメントを確認していると

「V$PARAMETERのISSYS_MODIFIABLE列の値がDEFERREDの場合は、DEFERREDを指定する必要があります。」

recyclebinのISSYS_MODIFIABLE列の値はDEFERREDだったので

ALTER SYSTEM SET RECYCLEBIN = OFF DEFERRED ;

と指定しないといけないらしい。

どうやら11gからの仕様っぽい

ちなみに、recyclebinのoffに設定変更してもすでにrecyclebinに削除されているオブジェクトは残ったままの様で次回のセッションから有効になるみたい。