我尝试通过终端安装Google API客户端库,并获得以下结果:
$ sudo pip install google-api-python-client
The directory '/home/masterqiao/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/masterqiao/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: google-api-python-client in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: httplib2<1dev,>=0.9.2 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already satisfied: oauth2client<5.0.0dev,>=1.5.0 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already satisfied: uritemplate<4dev,>=3.0.0 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already satisfied: six<2dev,>=1.6.1 in /usr/local/lib/python2.7/dist-packages (from google-api-python-client)
Requirement already satisfied: pyasn1>=0.1.7 in /usr/local/lib/python2.7/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
Requirement already satisfied: pyasn1-modules>=0.0.5 in /usr/local/lib/python2.7/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
Requirement already satisfied: rsa>=3.1.4 in /usr/local/lib/python2.7/dist-packages (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
答案 0 :(得分:1)
答案 1 :(得分:1)
你可以用两种方式做到这一点
选项1:
repository.getAllEvents()
.toObservable()
.flatMap(new Function<Events, Observable<Event>>() {
@Override
public Observable<Event> apply(@NonNull Events events) throws Exception {
return Observable.fromIterable(events.getEvents());
}
})
.groupBy(new Function<Event, Date>() {
@Override
public Date apply(@NonNull Event event) throws Exception {
return event.when;
}
})
.flatMap(new Function<GroupedObservable<Date, Event>, Observable<Object>>() {
@Override
public Observable<Object> apply(@NonNull GroupedObservable<Date, Event> dateEventGroupedObservable) throws Exception {
final Date key = dateEventGroupedObservable.getKey();
return dateEventGroupedObservable.toList().toObservable().flatMap(new Function<List<Event>, ObservableSource<?>>() {
@Override
public ObservableSource<?> apply(@NonNull List<Event> events) throws Exception {
return Observable.just(new Pair<Date, List<Event>>(key, events));
}
});
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new Observer<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Object o) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
选项2:
varad@adithya-pc /tmp/venv/testPythonStacks $ source bin/activate
(testPythonStacks) varad@adithya-pc /tmp/venv/testPythonStacks $ pip install --upgrade google-api-python-client
Collecting google-api-python-client
Downloading google_api_python_client-1.6.2-py2.py3-none-any.whl (52kB)
100% |████████████████████████████████| 61kB 366kB/s
Requirement already up-to-date: six<2dev,>=1.6.1 in ./lib/python2.7/site-packages (from google-api-python-client)
Collecting uritemplate<4dev,>=3.0.0 (from google-api-python-client)
Downloading uritemplate-3.0.0-py2.py3-none-any.whl
Collecting oauth2client<5.0.0dev,>=1.5.0 (from google-api-python-client)
Downloading oauth2client-4.0.0-py2.py3-none-any.whl (184kB)
100% |████████████████████████████████| 194kB 1.0MB/s
Collecting httplib2<1dev,>=0.9.2 (from google-api-python-client)
Downloading httplib2-0.10.3.tar.gz (204kB)
100% |████████████████████████████████| 204kB 908kB/s
Collecting rsa>=3.1.4 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
Downloading rsa-3.4.2-py2.py3-none-any.whl (46kB)
100% |████████████████████████████████| 51kB 1.9MB/s
Collecting pyasn1-modules>=0.0.5 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
Downloading pyasn1_modules-0.0.8-py2.py3-none-any.whl
Collecting pyasn1>=0.1.7 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client)
Downloading pyasn1-0.2.3-py2.py3-none-any.whl (53kB)
100% |████████████████████████████████| 61kB 1.7MB/s
Building wheels for collected packages: httplib2
Running setup.py bdist_wheel for httplib2 ... done
Stored in directory: /home/varad/.cache/pip/wheels/ca/ac/5f/749651f7925b231103f5316cacca82a487810c22d30f011c0c
Successfully built httplib2
Installing collected packages: uritemplate, pyasn1, rsa, httplib2, pyasn1-modules, oauth2client, google-api-python-client
Successfully installed google-api-python-client-1.6.2 httplib2-0.10.3 oauth2client-4.0.0 pyasn1-0.2.3 pyasn1-modules-0.0.8 rsa-3.4.2 uritemplate-3.0.0
t