星期二, 5月 23, 2017

grive2 with openSUSELeap42.2小記

grive2 with openSUSELeap42.2小記

今天在 facebook 看到有朋友貼 grive 的相關文章, 很早之前有試過 GNOME 的 online account with google, 不過那個時候還沒有成熟, 看到朋友回說這個是 command line 工具, 就順手玩了一下.

OS: openSUSE Leap 42.2
套件:  grive2

Github 網站

目前在 openSUSE Leap 42.2 上面, grive2 是不穩定的套件, 抱著實驗的心情來嘗試

安裝相關套件
這邊偷懶的方式我使用 OneClickInstallCLI ,  作法為 OneClickInstallCLI 後面接 .ymp位置

# OneClickInstallCLI https://software.opensuse.org/ymp/home:darkhado:openSUSE/openSUSE_Leap_42.2/grive2.ymp
If you continue, the following repositories will be subscribed:
* http://download.opensuse.org/repositories/home:/darkhado:/openSUSE/openSUSE_Leap_42.2/
If you continue, the following software packages will be installed:
* grive2
Continue? y/N 輸入 y

接下來 Import Key 當然選 Trust
2017-05-23 23-30-59 的螢幕擷圖.png


執行完畢之後就安裝完成了 :)
進行相關設定
建立同步資料夾, 這邊我跟文章一樣在家目錄建立 google_drive 目錄
> mkdir   ~/google_drive

進入資料夾
> cd   ~/google_drive/

執行驗證要求, 開啟裡面的連結
> grive -a
-----------------------
Please go to this URL and get an authentication code:

https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fdocs.google.com%2Ffeeds%2F+https%3A%2F%2Fdocs.googleusercontent.com%2F+https%3A%2F%2Fspreadsheets.google.com%2Ffeeds%2F&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=22314510474.apps.googleusercontent.com

-----------------------
Please input the authentication code here:

會跳出驗證要求畫面, 點選 ALLOW
2017-05-23 23-41-06 的螢幕擷圖.png

會出現authentication code
2017-05-23 23-42-57 的螢幕擷圖.png
將他貼到
-----------------------
Please input the authentication code here:

接下來就會開始同步資料夾

同步完之後觀察資料夾
  • 資料夾下會有 .grive 以及.grive_state
  • 發現沒有同步的很完整, 發現如果是 google document 會被 ignored


> grive -V
config file name "./.grive"
Reading local directories
file .grive is ignored by grive
file .grive_state is ignored by grive
Reading remote server file list
file "testfile" is a google document, ignored
folder "./grive_test" is in sync
file "Portus 淺談" is a google document, ignored
file "2013-Q1 服務學習選修名單" is a google document, ignored
file "2014-Q1 - 交大資工系服務學習項目" is a google document, ignored
file "20161022 Docker and openSUSE workshop" is a google document, ignored

結論, 可能還要再觀察


Reference:


~ enjoy it

星期二, 5月 09, 2017

20170509_python_Python程式設計實務_練習小記

20170509_python_Python程式設計實務_練習小記

Github:

Client: openSUSE Leap 42.2 with vi and PyCharm

今天練習猜數字程式, 另外把 Pycharm 升級到 2017.1.2 版本
  • VCS 要 push 的時候必須要在console輸入github 帳密才能 push
    • Linux 版本有這個問題, Mac 沒有
      • 但是 linux 如果是 command line 去使用 /opt/pycharm-community-2017.1.2/bin/pycharm.sh 就可以, 目前原因待查

練習相關檔案

檔案: 5-3.py

# -*- coding: utf-8 -*-

import random

game_count = 0
all_counts = []
while True:
  game_count += 1
  guess_count = 0
  answer = random.randint(0,99)
  while True:
      guess = int(input("請猜一個數字(0-99)"))
      guess_count += 1
      if guess == answer:
          print("恭喜你,猜中了")
          print("你總共猜了" + str(guess_count) + "次")
          all_counts.append(guess_count)
          break;
      elif guess > answer:
          print("您猜的數字太大了")
      else:
          print("您猜的數字太小了")
  #這邊有發生 pycharm console輸入的 值會產生錯誤, 但是在 command line 下就沒有問題
  onemore = input("還要再玩一次嗎?(Y/N)")
  if onemore != 'Y' and onemore != 'y':
      print("歡迎下次再來玩")
      print("您的成績如下")
      print(all_counts)
      print("平均猜中次數" + str(sum(all_counts)/float(len(all_counts))))
      break;




~ enjoy it